home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 4 / BBS in a Box - Macintosh - Volume IV (January 1992) (BBS in a Box).iso / Files / Util / Df-Dz / DistillPS3.0b1.cpt / still.ps < prev   
Encoding:
Text File  |  1989-10-09  |  76.3 KB  |  2,452 lines  |  [TEXT/MACA]

  1. %!PS-Adobe-2.1
  2. %%Title: still.ps
  3. %%Creator: Glenn Reid, Adobe Systems <greid@adobe.com>
  4. %%CreationDate:    greid Wed Jul  6 18:02:53 1988
  5. %%CreationDate: LAST EDIT: Wed Aug 23 14:50:27 1989
  6. %%VMUsage: 58008 (approx)
  7. %%EndComments
  8.  
  9. % Notice: Copyright 1988 1989 Adobe Systems Incorporated.  All Rights Reserved.
  10. /ifnotdef { %def
  11.   % only does the "def" if the key has not already been defined:
  12.     1 index where { pop pop pop }{ def } ifelse
  13. } bind def
  14. /opt /ifnotdef load def
  15.  
  16. /adobe_distill 155 200 add dict def    % 155 required by still.ps
  17. /adobe_still_version ((V 1.0d release 12 edit 0)) def
  18.  
  19. % QUICKY INTRODUCTION:
  20. %    This program takes one PostScript file and gives you back an
  21. %    equivalent one that should be better and faster, but may not be.
  22. %
  23. %    About one or two pages down are lots of comments on what this
  24. %    program is and how it works.  The options have been bubbled to
  25. %    the top for convenience to the poor people who have to edit them.
  26.  
  27. % WARNINGS AND ADVICE:
  28. %    The distillery tries very hard to work in the face of amazingly
  29. %    difficult circumstances.  It is not possible to anticipate or
  30. %    correctly handle all situations, so the distillery has been set
  31. %    up with parameters that you can tweak to encourage it to do its
  32. %    best, not unlike an autotrace tool or curvefitter that needs some
  33. %    hints.  If you are experiencing difficulty or getting incorrect
  34. %    results, take a look at the following list of parameters and try
  35. %    tweaking some of them that look appropriate.
  36.  
  37. % OPTIONS:
  38. /debug true  opt        % generate debugging messages
  39. /messages false opt        % generate more debugging messages (verbose!)
  40. /trace true  opt        % print tracing messages like "page: 3"
  41. /substitutefonts true opt    % substitute fonts if guess_font fails....
  42. /includeuserfonts true opt    % copy embedded user-defined fonts to output?
  43. /printpages false opt        % do you want the pages to print?
  44. /optimize true  opt        % optimize "show" to "widthshow", etc.
  45. /tolerance .05 opt        % for "essentially equal to" operations
  46. /cachefonts true opt        % use the "/F1 <font> def" cache technique
  47. /cachedir 60 dict opt        % how many font dicts to cache (optimization)
  48. /includeprologue true opt    % output files with/without prologue
  49. /usernametrack 500 opt        % how many names to track in user-defined fonts
  50.                 % (uses much VM; decrease if no user fonts)
  51. /hexformat 78 opt        % width of column for formatted hex data
  52. /flushout false opt        % flush output file often, for debugging
  53. /trylandscape false opt        % attempt to improve text in landscape docs
  54.                 % (doesn't really work yet)
  55. /transformhacks false def    % nullify 'transform' and 'itransform' to
  56.                 % keep output from rounding to resolution
  57.  
  58. % things that affect the proc set itself:
  59. /colormodel /RGB opt        % either /RGB or /CMYK for color model
  60. /imagehacks true opt        % if images fail, try making this "true"
  61.  
  62. % NO USER-SERVICEABLE PARTS BELOW THIS LINE (other than documentation)
  63. /procset_version
  64.   imagehacks not { %if
  65.     colormodel /CMYK ne { %if
  66.       (0.1200)            % standard version
  67.     }{ %else
  68.       (0.1201)            % standard + CMYK color
  69.     } ifelse
  70.   }{ %else
  71.     colormodel /CMYK ne { %if
  72.       (0.1202)            % standard + image hacks
  73.     }{ %else
  74.       (0.1203)            % standard + image hacks + CMYK color
  75.     } ifelse
  76.   } ifelse
  77. def
  78.  
  79. % OVERVIEW:
  80. %    This is a meta-utility program that "distills" any PostScript
  81. %    language program into a simpler one.  The resulting program
  82. %    will print exactly the same page as the original, but all
  83. %    unnecessary execution overhead is eliminated and the file is
  84. %    clean, uniform, and fast.
  85. %
  86. % RELEASE NOTES: [recent changes and details]
  87. %    First public release: 2/10/89
  88. %    Second release (numbered release 8): 2/17/89
  89. %        - reimplemented guess_font routines
  90. %        - added support for color; not careful about RGB->CMYK->RGB
  91. %        - added selective printing of pages during distill
  92. %    Release 9: 3/2/89
  93. %        - fixed color-induced [major efficiency loss] bug
  94. %        - produces %%BoundingBox and %%PageBoundingBox info (atend)
  95. %        - works better (bugs fixed) on rotated (landscape) documents
  96. %        - fixed horrible bug related to CTM that made it resolution-
  97. %          dependent in some cases.
  98. %        - included flag to omit the prologue on output if desired
  99. %        - moved some of the flags to the beginning of the file
  100. %        - improved prologue code to simulate CMYK color with RGB
  101. %    Release 10: 3/10/89
  102. %        - fixed bug related to rotated text
  103. %        - fixed rotated charpath bug mentioned in KNOWN PROBLEMS list
  104. %        - fixed bug with "closepath" followed by "rmoveto"
  105. %        - '=' and 'print' operators now pass data through to output
  106. %        - bug fixes for and much better support of user-defined fonts
  107. %        - (edit 07) fixed "undefined" "fd" problem.
  108. %        - (edit 08) took out redefinitions of '=' and 'print'; fixed
  109. %          a different "undefined" "fd" problem!
  110. %    Release 11: 6/7/89
  111. %        - release numbered (V 1.0d release 11 edit 4)
  112. %        - most reported bugs fixed
  113. %        - optimization added for vertical and horizontal lines
  114. %        - code from Anders Blomdell for arrayeq and formatted hex output
  115. %        - fixed (I think) problems with dropped lines in MacDraw files
  116. %        - declared "Towneley Plays" test file to be incorrigible
  117. %        - adjusted ProcSet comments
  118. %        - fixed bug that generated extra blank pages at end of doc.
  119. %    Release 12: 8/21/89
  120. %        - release numbered (V 1.0d release 12 edit 0)
  121. %        - put "PROLOGUE begin" on each page instead of in Document-
  122. %          Setup; works around bugs in old versions of TranScript
  123. %        - added "imageflush" to deal with strange image padding
  124. %        - introduced "colormodel" to allow RGB or CMYK color
  125. %        - parameterized "transform" hack to permit on/off selection
  126. %        - subsetted ProcSets depending on what hacks you needed
  127. %        - added "trylandscape" parameter to help avoid rotated text
  128. %        - read KNOWN PROBLEMS if your Mac files lose graphics
  129. %
  130. % MANY USES:
  131. %    * If you archive documents in PostScript format, they can often
  132. %      be made more compact and efficient by distilling them.
  133. %    * As a development tool, you can see what your program is
  134. %      really doing, and how simple and fast the driver could be.
  135. %    * Distilled files can be used as an interchange format,
  136. %      since arbitrary PostScript files can be converted to this
  137. %      uniform representation.
  138. %    * If your program can parse distilled files, then any arbitrary
  139. %      PostScript program can be used as input after distilling.
  140. %    * Many others.
  141. %
  142. % FEATURES:
  143. %    * correctly distills arbitrarily complex PostScript programs
  144. %    * output is universal, simple, and in default user coordinates
  145. %    * handles "charpath", "image", "imagemask", "awidthshow", etc.
  146. %    * correctly follows "save", "restore", "gsave", "grestore"
  147. %    * re-encodes fonts automatically to match application encoding
  148. %    * reduces prologue size to only about 25-30 lines
  149. %    * For machine-generated code:
  150. %        * output files are almost always SMALLER than original files
  151. %         * output files are almost always FASTER than original files
  152. %    * optimizes "show" to use "widthshow" whenever possible.
  153. %    * uses save/restore at page boundaries
  154. %    * observes structuring conventions and page independence
  155. %    * caches font dictionaries instead of repeating "findfonts"
  156. %    * output is normally VERY fast.
  157. %
  158. % HOW TO USE:
  159. %    This program redefines a bunch of operators, and is invoked
  160. %    with the word "distill".  This file has to precede the job it is
  161. %    distilling, and you have to invoke it by calling "distill".
  162. %
  163. %    PRINTERS:
  164. %        In general, start with this file (still.ps), add the word
  165. %        "distill" at the end (to invoke the procedure), and tack
  166. %        any PostScript language file onto the end.  Send this to
  167. %        your favorite PostScript printer with an appropriate
  168. %        end-of-file indication at the end.  Results will
  169. %        be returned across communication channel, often to a log
  170. %        file somewhere (Unix: /usr/adm/printername.log)
  171. %
  172. %    INTERPRETERS: if you have an interpreter with a file system
  173. %        handy, first type "(still.ps) run" to load this file, then
  174. %        distill your file like this: "(prog.ps) distill".  It will
  175. %        write the results in "prog.psx" (appends an x to the file
  176. %        name you give it).
  177. %
  178. %    MACINTOSH: I have written a small Mac utility that is called
  179. %        "DistillPS" (an adaptation of "SendPS") that will perform the
  180. %        above PRINTER steps for you.  If you are an Adobe registered
  181. %        developer, you can get a copy directly from Adobe (or see
  182. %        posting in USENET comp.binaries.mac group).
  183. %
  184. % BACKGROUND
  185. % The basic idea is to execute the input file completely, with all of
  186. % the painting operators redefined.  When one of these operators is
  187. % called by the client program, the distillery will write the
  188. % path the output file (with all coordinates normalized to the default
  189. % userspace coordinate system).  Note that it will usually take LONGER
  190. % to distill a file than it would to print it, because it executes the
  191. % whole program, and much of it in a redefined state (slower).  Usually
  192. % only about 20% slower than original print time to distill.
  193. %
  194. % The routines in this file are broken down into several areas.  Most
  195. % of them are concerned with writing things to the output file,
  196. % actually, although there are two other interesting areas.  The first
  197. % are the graphics state procedures, which attempt to keep track of the
  198. % graphics state and, when a painting op is called, it writes out any
  199. % changes to the graphics state since the last time it was called.  This
  200. % keeps each painting op from having to write gstate itself.  The other
  201. % interesting procs are simply the redefinitions of the painting ops
  202. % themselves.
  203. %
  204. % KNOWN COMPATIBLE PROGRAMS
  205. % The following applications have been tested (with some version of the
  206. % driver, at least), successfully:
  207. %    Lotus Manuscript
  208. %    Macintosh "LaserPrep" (all documents, I think)
  209. %    DEC's VaxDocument
  210. %    Scribe
  211. %    PageMaker
  212. %    Frame Maker
  213. %    Adobe Illustrator
  214. %    TranScript (ditroff and enscript drivers)
  215. %    Pedigree Plot package (incomplete testing)
  216. %    idraw (Stanford X-window drawing package)
  217. %
  218. % KNOWN PROBLEMS:
  219. %    The Macintosh printing manager insists on downloading its
  220. %    prologue procedures outside the server loop, making it
  221. %    impossible to redefine some of the operations.  This results
  222. %    in the distillery "missing" some of the drawing instructions,
  223. %    because it works by redefining operators.  If you experience
  224. %    this, try getting a full command-K PostScript file and making
  225. %    sure that LaserPrep is NOT downloaded into your printer when
  226. %    you distill.  If you have suggestions about how to really solve
  227. %    this problem, please let me know.
  228. %
  229. %    Clipping isn't handled correctly.
  230. %
  231. %    The bounding box for text is a crude estimate.
  232. %
  233. %    Some font tricks are difficult or impossible to distill correctly.
  234. %    Especially those that involve sharing various parts of a font
  235. %    between different font dictionaries, or changing the contents
  236. %    of a font after "definefont" has been executed.  Luckily there
  237. %    aren't many programs that do things like that.
  238. %
  239. %    Hand-written PostScript language programs (especially those
  240. %    that take advantage of looping constructs) may get BIGGER
  241. %    when you distill them, because the Distillery unrolls all loops.
  242. %    It is really intended for machine-generated files, but it should
  243. %    still work on programs tightly coded by hand (like Cookbook
  244. %    examples).
  245. %
  246. %    Use of the "put" and "putinterval" operators to overwrite
  247. %    string bodies can confuse the optimization technique.  If you
  248. %    see strange output (wrong characters printed, especially),
  249. %    try changing "/optimize true def" to "/optimize false def"
  250. %    at the very beginning of this program.
  251. %
  252. %    Programs that use the "transform" operator to make resolution-
  253. %    rounding decisions may have the output file bound to a specific
  254. %    resolution.  The last ProcSet (called "hacks") redefines a few
  255. %    operators to try to work around this.  Output file is still
  256. %    device-independent in any case, but might look different.
  257. %
  258. %    Distillery relies on bug in save/restore related to string bodies
  259. %    to preserve some information across save/restore. It is localized
  260. %    to the "adobe_staticvar" procedure set, but may not always work.
  261. %
  262. %    In order to optimize re-encoding of fonts, the distillery takes
  263. %    an educated guess that the first re-encoded font it sees will
  264. %    have a representative encoding vector ("stdvec").  If this
  265. %    first font is not encountered before other marks are made, the encoding
  266. %    vector cannot be produced in the %%BeginSetup section, and the still
  267. %    is forced to repeat the vector every time a font is used.  Work
  268. %    is in progress on a heuristic to improve this.
  269. %
  270. %       In order to avoid building up the dictionary stack during
  271. %       execution, all definitions are made in one dictionary
  272. %       (PROLOGUE) and it is not explicitly brought to the top of
  273. %       the dictionary stack for each operation (to avoid
  274. %       "dictstackoverflow" errors).  Most of the identifiers have
  275. %       been chosen to be reasonably unique, but there could be a
  276. %       conflict if user programs use the same names.
  277. %
  278. %    Sometimes generates unnecessarily verbose code in the presence
  279. %    of lots of save/restores in original file.  Try distilling the
  280. %    output a second time to improve this (like whiskey)....
  281. %
  282. %    Some of the ProcSets depend on each other in weird ways, which
  283. %    is wrong, since only the script should depend on the procset
  284. %    definitions.  Eventually this will get fixed.
  285. %
  286. %    Does not always work correctly with user-defined fonts, especially
  287. %    those defined by the standard TeX driver (unfortunately).  In
  288. %    particular, TeX bitmap fonts that are defined and have characters
  289. %    added on the fly are almost impossible to deal with reliably in this
  290. %    distillery approach.
  291.  
  292. %%BeginProcSet: distill_defs 1.0 0
  293. /setpacking where { pop currentpacking true setpacking } if
  294. /firstmtx matrix currentmatrix def
  295.  
  296. /bdef { bind def } bind def
  297.  
  298. /*flushfile /flushfile load ifnotdef
  299.  
  300. printpages not { %if
  301.     /showpage { erasepage initgraphics } bind def
  302. } if
  303.  
  304. /currentcmykcolor where { pop }{ %else
  305.     /currentcmykcolor { %def
  306.         currentrgbcolor 3 { 1 exch sub 3 1 roll } repeat 0
  307.     } bind def
  308. } ifelse
  309. colormodel /RGB eq {
  310.     /currentCOLOR { 0 currentrgbcolor } bdef
  311.     /setCOLOR { setrgbcolor pop } bdef
  312. }{
  313.     /currentCOLOR { currentcmykcolor } bdef
  314.     /setCOLOR { setcmykcolor } bdef
  315. } ifelse
  316.  
  317. /setpacking where { pop setpacking } if
  318. %%EndProcSet distill_defs 1.0 0
  319.  
  320. %%BeginProcSet: Adobe_staticvar 1.0 0
  321.     % this procedure set implements the "magic" stuff to hide numbers
  322.     % and other things where they will not be subject to save/restore
  323.     /magicval { 8 string } bdef
  324.     /hideval { %def    % /name int :    % "hideval" uses save/restore bug!
  325.     exch load dup 0 (\040\040\040\040\040\040\040\040) putinterval
  326.     exch (\040\040\040\040\040\040\040\040) cvs
  327.     dup length 8 exch sub exch putinterval
  328.     } bdef
  329.     /magicbool { 5 string } bdef
  330.     /hidebool { %def    % /name int :    % "hideval" uses save/restore bug!
  331.     exch load dup 0 (\040\040\040\040\040) putinterval
  332.     exch (\040\040\040\040\040) cvs 0 exch putinterval
  333.     } bdef
  334.     /cvnum { cvx exec } bdef    % makes hidden val back into an integer
  335.     /cvbool { cvx exec } bdef    % makes hidden val back into a boolean
  336.     /hidefontname { %def
  337.     % hides a font name in a string body, for use in %%DocumentFonts
  338.     scratch cvs
  339.     % look to see if it is already in the docfonts string:
  340.     % lots of hacks to search for (FontName\n), not just (FontName)
  341.     save    % cause we're using memory for temporary string
  342.         adobe_distill begin
  343.         1 index length 1 add string /tmpstring exch def
  344.         tmpstring dup length 1 sub (\040) 0 get put
  345.         tmpstring 0 3 index putinterval
  346.         pagefonts tmpstring search {pop pop pop false}{pop true} ifelse
  347.         docfonts tmpstring search {pop pop pop false}{pop true}ifelse
  348.         end
  349.     3 -1 roll restore        % roll save object past booleans
  350.  
  351.     % first deal with docfonts, then with pagefonts booleans
  352.     { %ifelse
  353.         exch    % extra boolean for page fonts
  354.         dup dfontcount cvnum 1 index length add 1 add
  355.         docfonts length lt {
  356.         dup docfonts exch dfontcount cvnum exch putinterval
  357.         length 1 add dfontcount cvnum add /dfontcount exch hideval
  358.         docfonts dfontcount cvnum 1 sub (\040) putinterval
  359.         }{ %else
  360.         pop (% No more room for fonts in document font list\n) d=
  361.         } ifelse
  362.         messages { %if
  363.         (document fonts: ) pr=
  364.         docfonts 0 dfontcount cvnum getinterval d= flush
  365.         } if
  366.         exch % page font boolean still on stack, under "dup"ed string
  367.     }{ } ifelse
  368.     { %ifelse
  369.         pfontcount cvnum 1 index length add 1 add
  370.         pagefonts length lt {
  371.         dup pagefonts exch pfontcount cvnum exch putinterval
  372.         length 1 add pfontcount cvnum add /pfontcount exch hideval
  373.         pagefonts pfontcount cvnum 1 sub (\040) putinterval
  374.         }{ %else
  375.         pop (% No more room for fonts in page font list\n) d=
  376.         } ifelse
  377.         messages { %if
  378.         (page fonts: ) pr=
  379.         pagefonts 0 pfontcount cvnum getinterval d= flush
  380.         } if
  381.     }{ pop } ifelse
  382.     } bdef
  383. %%EndProcSet: Adobe_staticvar 1.0 0
  384.  
  385. %%BeginProcSet: distill 1.0 0
  386. /setpacking where { pop currentpacking true setpacking } if
  387.  
  388. /adobe_distill dup where { pop pop }{ 165 200 add dict def } ifelse
  389.  
  390. % some variables
  391.     % magic variables depending on "hideval", not subject to save/restore
  392.     /pagecount magicval def    /pagecount 1 hideval
  393.     /beginsetup magicbool def    /beginsetup true hidebool
  394.     /lastshowpage magicbool def    /lastshowpage false hidebool
  395.     /begunpage magicbool def    /begunpage false hidebool
  396.     /?distilling magicbool def    /?distilling true hidebool
  397.  
  398.     /dfontcount magicval def     /dfontcount 0 hideval
  399.     /pfontcount magicval def    /pfontcount 0 hideval
  400.     /docfonts 40 30 mul string def        % room for 40 30-byte font names
  401.     /pagefonts 40 30 mul string def        % room for 40 30-byte font names
  402.     /LLx magicval def        /LLx 10000 hideval
  403.     /LLy magicval def        /LLy 10000 hideval
  404.     /URx magicval def        /URx -10000 hideval
  405.     /URy magicval def        /URy -10000 hideval
  406.     /docLLx magicval def    /docLLx 10000 hideval
  407.     /docLLy magicval def    /docLLy 10000 hideval
  408.     /docURx magicval def    /docURx -10000 hideval
  409.     /docURy magicval def    /docURy -10000 hideval
  410.  
  411.     /optim optimize def
  412.     /scratch 128 string def
  413.     /fontcount 0 def
  414.     /indentlevel 0 def
  415.     /ANYtype null def
  416.     /insideproc false def
  417.     /Dfont null def
  418.     /Ffont null def
  419.     /Fname null def
  420.     /lastshow false def
  421.     /imageproc null def
  422.     /imagematrix null def
  423.     /imagedepth null def
  424.     /imageheight null def
  425.     /imagewidth null def
  426.     /imagebuffsize null def
  427.     /unames usernametrack dict def  % for keeping track of user-defined names
  428.  
  429. % a few of them go into userdict:
  430. /cvp {
  431.     messages { % ifelse
  432.     (                     ) cvs pr= (\040) pr=
  433.     }{ pop } ifelse
  434. } bdef
  435. /pr= { messages { rprint }{ pop } ifelse } bdef
  436. /d= { messages { r= }{ pop } ifelse } bdef
  437.  
  438. /distill {
  439.     adobe_distill begin
  440.     debug{(%!PS-Adobe-2.1 debug version ) rprint adobe_still_version == }if
  441.     userdict /orig_dictcount countdictstack put
  442.     count 0 eq { %ifelse
  443.         /INfile (%stdin) def
  444.         /OUTfile (%stdout) def
  445.         /fd (%stdout) (w) file def
  446.         initstill
  447.         writeprologue
  448.         initgstate
  449.         INfile (r) file cvx exec
  450.         writetrailer
  451.     }{ %else
  452.         dup type /stringtype ne { %if
  453.         (\n% Distill Error; invoked with bogus file name: ) print
  454.         == (\n) print flush
  455.         stop
  456.         } if
  457.         /filenameforall where { pop }{ %ifelse
  458.         (\n% Distill Error; invoked with file name: ) print ==
  459.         (% This interpreter cannot open files directly.) =
  460.         (% Please add "distill" at end of file and concatenate with) =
  461.         (% file to be distilled.) = (\n) print flush
  462.         stop
  463.         } ifelse
  464.         initgraphics
  465.         /saveall save def
  466.         /INfile exch def
  467.         /OUTfile INfile length 1 add string def
  468.         OUTfile 0 INfile putinterval
  469.         OUTfile dup length 1 sub (x) 0 get put
  470.         trace { (output file: ) rprint OUTfile == } if
  471.         /outfile OUTfile (w) file def
  472.         /fd /outfile load def
  473.         initstill
  474.         writeprologue
  475.         initgstate
  476.         debug { %ifelse
  477.             INfile run
  478.         }{ % else
  479.             { INfile run } stopped { % if
  480.              errordict begin $error begin
  481.                 (\n%%[Error: ) wout
  482.                 /errorname load =string cvs wout
  483.                 (; OffendingCommand: ) wout
  484.                 /command load =string cvs wout (]%%) wout writeNL
  485.                 (STACK:) writeop /ostack load type /arraytype eq {
  486.                 ostack { =string cvs writeop } forall
  487.                 } if
  488.                 fd systemdict /flushfile get exec
  489.                 handleerror
  490.             end end
  491.             } if
  492.         } ifelse
  493.         writetrailer
  494.         fd closefile
  495.         countdictstack orig_dictcount sub { end } repeat
  496.         clear
  497.         saveall { restore } stopped { %if
  498.         trace { (couldn't restore after distill.) r= } if
  499.         } if
  500.     } ifelse
  501.    end
  502. } bdef
  503.  
  504. % the rest of them go in "adobe_distill"
  505. adobe_distill begin
  506.     /setdistill { %def
  507.     /?distilling exch hidebool
  508.     } bdef
  509.  
  510.     /initstill { %def
  511.     /beginsetup true hidebool
  512.     /lastshowpage false hidebool
  513.     /begunpage false hidebool
  514.     /pagecount 1 hideval
  515.     /STDvec 0 hideval
  516.     /PAGEvec 0 hideval
  517.     /dfontcount 0 hideval
  518.     /pfontcount 0 hideval
  519.     /LLx 10000 hideval  /LLy 10000 hideval
  520.     /URx -10000 hideval /URy -10000 hideval
  521.     /docLLx 10000 hideval  /docLLy 10000 hideval
  522.     /docURx -10000 hideval /docURy -10000 hideval
  523.     /SharedFontDirectory where { %ifelse
  524.         /SharedFontDirectory get
  525.     }{ /FontDirectory load } ifelse
  526.     /FontDirectory exch def
  527.     0 1 pagefonts length 1 sub { pagefonts exch 0 put } for
  528.     0 1 docfonts length 1 sub { docfonts exch 0 put } for
  529.     } bdef
  530.     debug { %if
  531.     /BB {
  532.         debug {
  533.         (% BBox: ) pr=
  534.         LLx pr= ( ) pr= LLy pr= ( ) pr=
  535.         URx pr= ( ) pr= URy pr= (\n) pr= flush
  536.         (% DocBBox: ) pr=
  537.         docLLx pr= ( ) pr= docLLy pr= ( ) pr=
  538.         docURx pr= ( ) pr= docURy pr= () r= flush
  539.         } if
  540.     } bdef
  541.     } if
  542.     /?box { %def    % X Y
  543.     dup URy cvnum gt { dup /URy exch cvi hideval } if
  544.     dup LLy cvnum lt { dup /LLy exch cvi hideval } if pop
  545.     dup URx cvnum gt { dup /URx exch cvi hideval } if
  546.     dup LLx cvnum lt { dup /LLx exch cvi hideval } if pop
  547.     } bdef
  548.     /doc?box {
  549.     dup docURy cvnum gt { dup /docURy exch cvi hideval } if
  550.     dup docLLy cvnum lt { dup /docLLy exch cvi hideval } if pop
  551.     dup docURx cvnum gt { dup /docURx exch cvi hideval } if
  552.     dup docLLx cvnum lt { dup /docLLx exch cvi hideval } if pop
  553.     } bdef
  554.     /pageBBox-docBBox {
  555.     LLx cvnum LLy cvnum doc?box
  556.     URx cvnum URy cvnum doc?box
  557.     } bdef
  558.     /writeRmove { %def
  559.     2 copy lineY sub exch lineX sub exch
  560.     dup 0.0 eq { pop writenum (x) writeop }{ %ifelse
  561.         1 index 0.0 eq { writenum (y) writeop pop }{ %ifelse
  562.         writepair (r) writeop
  563.         } ifelse
  564.     } ifelse
  565.     2 copy ?box
  566.     /lineY exch store /lineX exch store
  567.     } bdef
  568.     /writelines { %def
  569.     counttomark REPEAT_LINETO_THRESHOLD gt { % ifelse
  570.         counttomark /lcount exch store
  571.         lcount -2 2 { %for
  572.         dup /rcount exch store
  573.         -2 roll 2 copy lineY sub exch lineX sub exch 4 -2 roll
  574.         2 copy ?box
  575.         /lineY exch store /lineX exch store
  576.         rcount 2 roll
  577.         } for
  578.         lcount 2 idiv { writepair writeNL } repeat
  579.         lcount 2 idiv writenum (R) writeop
  580.     }{ % else
  581.         counttomark -2 2 { -2 roll writeRmove } for
  582.     } ifelse
  583.     } bdef
  584.     /writepath {
  585.     /closed false store
  586.     % optimize special case of just "moveto lineto stroke"
  587.     mark
  588.     % pathforall
  589.     { counttomark 2 gt { cleartomark false exit } if thruCTM true }
  590.     { counttomark 5 gt { cleartomark false exit } if thruCTM true }
  591.     { cleartomark false exit }
  592.     { cleartomark false exit }
  593.     pathforall { %ifelse
  594.         counttomark 5 ne { %ifelse
  595.         % degenerate case...
  596.         ischarpath counttomark 2 eq and {    % just moveto
  597.             2 copy ?box
  598.             writepair (m) writeop
  599.         } if
  600.         cleartomark
  601.         }{ %else
  602.         3 -1 roll pop
  603.         /?simplepath true store
  604.         simplepath astore pop
  605.         pop %mark
  606.         } ifelse
  607.     }{ %else
  608.         /?simplepath false store
  609.         mark
  610.         { % moveto
  611.         closed { (cp ) wout /closed false store } if
  612.         counttomark 2 gt { %if
  613.             counttomark 1 add 2 roll writelines 3 1 roll
  614.         } if
  615.         2 copy thruCTM /lineY exch store /lineX exch store
  616.         /closeX lineX store  /closeY lineY store
  617.         2 copy ?box
  618.         writeTpair (m) writeop
  619.         } % moveto proc
  620.         { %lineto proc
  621.         thruCTM count 490 gt { writelines } if
  622.         } % lineto
  623.         { % curveto
  624.         counttomark 6 gt { %if
  625.             counttomark 1 add 6 roll writelines 7 1 roll
  626.         } if
  627.         2 copy thruCTM /lineY exch store /lineX exch store
  628.         3 { %repeat
  629.             6 -2 roll 2 copy thruCTM
  630.             2 copy ?box
  631.             exch writenum writenum
  632.         } repeat (c) writeop 6 {pop} repeat
  633.         } % curveto
  634.         { % closepath
  635.         counttomark 0 gt { writelines } if
  636.         /closed true store
  637.         /lineX closeX store  /lineY closeY store
  638.         } % closepath
  639.         pathforall
  640.         counttomark 0 gt { writelines } if
  641.         pop %mark
  642.     } ifelse
  643.     } bdef
  644.     /hashpath { %def
  645.       % manufacture a [fairly] unique integer to represent a path:
  646.     -1                % initial value
  647.     { .5 add add 2 div add }    % moveto
  648.     { add sub }            % lineto
  649.     { add add sub add add add }    % curveto
  650.     { 1 add }            % closepath
  651.     pathforall
  652.     dup 100 lt { 10 mul truncate 10 div } if
  653.     } bdef
  654.     /hashencoding { %def
  655.       % manufacture a [fairly] unique integer for an encoding vector,
  656.       % by alternately adding then subtracting the length of the name.
  657.       % The alternation makes reordered lists with same names still come out
  658.       % with a different hash value (the "-1 exch" and the "mul" do this)
  659.     -1 exch 0 exch            % initial value: 0
  660.     { % forall
  661.         dup type /nametype eq { length }{ pop 1 } ifelse
  662.         2 index mul add    % multiply by 1 or -1 and add
  663.         exch -1 mul exch    % flip 1 and -1
  664.     } forall
  665.     exch pop            % get rid of -1, leave hash val
  666.     } bdef
  667.     /STDvec magicval def /STDvec 0 hideval
  668.     /PAGEvec magicval def /PAGEvec 0 hideval
  669.     /enc1 null def /enc2 null def
  670.     /diffencoding { %def
  671.     % check the "top128" boolean to see if it's worth reencoding them
  672.     /enc2 exch store /enc1 exch store    % enc2 is the new one
  673.     [
  674.         32 1 127 { %for                % 0 1 255 ??
  675.         dup dup enc2 exch get exch enc1 exch get
  676.         1 index eq { pop pop } if
  677.         } for
  678.     ]
  679.     } bdef
  680.     /indent { indentlevel { fd (  ) writestring } repeat } bdef
  681.     /++ { dup load 1 add store } bdef
  682.     /-- { dup load dup 1 ge { 1 sub } if store } bdef
  683.  
  684. end %adobe_distill
  685. /setpacking where { pop setpacking } if
  686. %%EndProcSet distill 1.0 0
  687.  
  688. %%BeginProcSet: distill_writetofile 1.0 0
  689. /setpacking where { pop currentpacking true setpacking } if
  690. /adobe_distill dup where { pop pop }{ 165 200 add dict def } ifelse
  691. adobe_distill begin
  692.     /writetrailer { %def    % :
  693.     stackptr 0 ne { stackshow } if
  694.     begunpage cvbool { %if
  695.         lastshowpage cvbool not { %if
  696.         ( /showpage {} def) writeop
  697.         } if
  698.         pagecount cvnum scratch cvs wout ( ENDPAGE\n) wout
  699.         (%%PageTrailer) writeop
  700.         (%%PageFonts: ) wout
  701.         pfontcount cvnum 0 eq { writeNL }{ %else
  702.         pfontcount cvnum 200 lt { %ifelse
  703.             pagefonts 0 pfontcount cvnum getinterval writeop
  704.         }{ %else
  705.             pagefonts (\040) search not { writeop }{ %else
  706.             writeop    % first one without the %%+
  707.             { %loop
  708.                 search { (%%+ ) wout writeop }{ %else
  709.                 (\000) search { writeop pop pop }{ pop } ifelse
  710.                 exit
  711.                 } ifelse
  712.             } loop
  713.             } ifelse
  714.         } ifelse
  715.         0 1 pfontcount cvnum { pagefonts exch 0 put } for
  716.         /pfontcount 0 hideval
  717.         } ifelse
  718.         LLx 10000 eq LLy 10000 eq or
  719.         URx -10000 eq URy -10000 eq or or not {
  720.         (%%PageBoundingBox: ) wout
  721.           LLx cvnum writenum LLy cvnum writenum
  722.           URx cvnum writenum URy cvnum writenum writeNL
  723.         } if
  724.         ( end %PROLOGUE) writeop
  725.         pageBBox-docBBox
  726.     } if
  727.     (%%Trailer) writeop
  728.     (%%Pages: ) wout pagecount cvnum writenum writeNL
  729.     (%%BoundingBox: ) wout
  730.       docLLx cvnum writenum docLLy cvnum writenum
  731.       docURx cvnum writenum docURy cvnum writenum writeNL
  732.     (%%DocumentFonts: ) wout
  733.     dfontcount cvnum 0 eq { writeNL }{ %else
  734.         dfontcount cvnum 200 lt { %ifelse
  735.         docfonts 0 dfontcount cvnum getinterval writeop
  736.         }{ %else
  737.         docfonts (\040) search not { writeop }{ %else
  738.             writeop    % first one without the %%+
  739.             { %loop
  740.             search { (%%+ ) wout writeop }{ %else
  741.                 (\000) search { writeop pop pop }{ pop } ifelse
  742.                 exit
  743.             } ifelse
  744.             } loop
  745.         } ifelse
  746.         } ifelse
  747.     } ifelse
  748.     (%%EOF) writeop
  749.     } bdef
  750.     /writecomments { %def
  751.     fd (%!PS-Adobe-2.1\n) writestring
  752.     fd (%%Title: ) writestring fd OUTfile writestring fd (\n) writestring
  753.     fd (%%Creator: Glenn Reid and still.ps ) writestring
  754.     fd adobe_still_version writestring fd (\n) writestring
  755.     fd (%%BoundingBox: (atend)\n) writestring
  756.     fd (%%Pages: (atend)\n) writestring
  757.     fd (%%ColorModel: ) writestring
  758.     fd
  759.         colormodel /CMYK eq { (CMYK) }{ (RGB) } ifelse
  760.     writestring fd (\n) writestring
  761.     includeprologue { %ifelse
  762.         fd (%%DocumentProcSets: Adobe_distill ) writestring
  763.         fd procset_version writestring  fd ( 0.0) writestring
  764.         fd (\n) writestring
  765.     }{ %else
  766.         fd (%%DocumentNeededProcSets: Adobe_distill ) writestring
  767.         fd procset_version writestring  fd ( 0.0) writestring
  768.         fd (\n) writestring
  769.     } ifelse
  770.     fd (%%EndComments\n) writestring
  771.     } bdef
  772.     /writeprologue { %def    % :
  773.     writecomments
  774.     includeprologue { %ifelse
  775.         fd (%%BeginProcSet: Adobe_distill ) writestring
  776.         fd procset_version writestring  fd ( 0.0) writestring
  777.         fd (\n) writestring
  778.         mark
  779.         (/PROLOGUE 31 40 add dict def)
  780.         ( % 31 procedure entries + room for 40 cached font dictionaries)
  781.         ( PROLOGUE begin)
  782.         ( /bdef { bind def } bind def    /ldef { load def } bdef)
  783.         ( /T { moveto show } bdef    /A { moveto ashow } bdef)
  784.         ( /W { moveto widthshow } bdef    /AW { moveto awidthshow } bdef)
  785.         ( /f /fill ldef            /R { { rlineto } repeat } bdef)
  786.         ( /r /rlineto ldef        /L { { lineto } repeat } bdef)
  787.         ( /m /moveto ldef        /l { moveto lineto stroke } bdef)
  788.         ( /x { 0 rlineto } bdef        /y { 0 exch rlineto } bdef)
  789.         ( /X { moveto 0 rlineto stroke } bdef)
  790.         ( /Y { moveto 0 exch rlineto stroke } bdef)
  791.         ( /c /curveto ldef        /cp /closepath ldef)
  792.         ( /s /stroke ldef        /w /setlinewidth ldef)
  793.         ( /g /setgray ldef        /j /setlinejoin ldef)
  794.         ( /d /setdash ldef        /F /setfont ldef)
  795.     imagehacks { %ifelse
  796.         ( /IMAGEMASK { imagemask imageflush } bdef)
  797.         ( /IMAGE { image imageflush } bdef)
  798.         ( /imageflush { %def (horrible hack for oddly padded image data))
  799.         (   { %loop)
  800.         (     currentfile read pop (%)0 get eq {)
  801.         (       currentfile 6 string readline { pop } if exit)
  802.         (     } if)
  803.         (   } loop)
  804.         ( } bdef)
  805.     }{ %else
  806.         ( /IMAGE /image ldef    /IMAGEMASK /imagemask ldef)
  807.     } ifelse
  808.     colormodel /CMYK eq { %ifelse
  809.         ( /CMYK /setcmykcolor where { /setcmykcolor get }{ %ifelse)
  810.         (   { %def)
  811.         (     1 sub 3 { 3 index add neg dup 0 lt { pop 0 } if 3 1 roll } repeat)
  812.         (     setrgbcolor)
  813.         (   } bind)
  814.         ( } ifelse def)
  815.     }{ %else
  816.         ( /RGB /setrgbcolor ldef)
  817.     } ifelse
  818.         ( /selectfont where { pop }{ %ifelse)
  819.         (     /selectfont { exch findfont exch scalefont setfont } bdef)
  820.         ( } ifelse)
  821.         ( /MF { exch findfont exch makefont setfont } bdef)
  822.         ( /FF /selectfont ldef)
  823.         ( /DF { selectfont currentfont def } bdef)
  824.         ( /BEGINPAGE { pop /pagesave save def } bdef)
  825.         ( /ENDPAGE { pop pagesave restore showpage } def)
  826.         ( /REMAP { %def)
  827.         (   FontDirectory 2 index known { pop pop pop } { %ifelse)
  828.         (     findfont dup length dict begin)
  829.         (       { 1 index /FID ne {def}{pop pop} ifelse } forall)
  830.         (       exch dup length 0 gt { /Encoding exch def }{ pop } ifelse)
  831.         (     currentdict end definefont pop)
  832.         (   } ifelse)
  833.         ( } bdef)
  834.         ( /RECODE { %def)
  835.         (    3 -1 roll 1 index findfont /Encoding get 256 array copy exch)
  836.         (    0 exch { %forall)
  837.         (     dup type/nametype eq)
  838.         (       { 3 {2 index} repeat put pop 1 add }{ exch pop }ifelse)
  839.         (    } forall pop 3 1 roll REMAP)
  840.         ( } bdef)
  841.         ( end %PROLOGUE)
  842.         % write all the above strings to the output file:
  843.         counttomark -1 1 { %for
  844.         -1 roll fd exch writestring fd (\n) writestring
  845.         } for
  846.         fd (%%EndProcSet: Adobe_distill ) writestring
  847.         fd procset_version writestring  fd ( 0.0) writestring
  848.         fd (\n) writestring
  849.         fd systemdict /flushfile get exec
  850.         pop %mark
  851.     }{ %else
  852.         fd (%%IncludeProcSet: Adobe_distill ) writestring
  853.         fd procset_version writestring  fd ( 0.0) writestring
  854.         fd (\n) writestring
  855.     } ifelse
  856.     fd (%%EndProlog\n) writestring
  857.     fd (%%BeginSetup\n) writestring
  858.     fd ( PROLOGUE begin\n) writestring
  859.     } bdef
  860.     /invalidatefonts { %def
  861.      % invalidate all remapped fonts, for page independence
  862.     FontDirectory { %forall
  863.         exch pop dup /FontInfo known { %ifelse
  864.         /FontInfo get dup /pleasemap known { %ifelse
  865.             begin (Glenn Reid)
  866.             pleasemap cvbool not {
  867.                 /pleasemap true hidebool
  868.             } if pop
  869.             end
  870.         }{ pop } ifelse
  871.         }{ pop } ifelse
  872.     } forall
  873.     currentfont null ne { % if
  874.         currentfont dup /FontInfo known { %ifelse
  875.         /FontInfo get dup /pleasemap known { %ifelse
  876.             begin /pleasemap true hidebool end
  877.         }{ pop } ifelse
  878.         }{ pop } ifelse
  879.     } if
  880.     % forcegstate
  881.     } bdef
  882.     /checksetup { %def
  883.     % called from "fontstate", "graphicstate", and "definefont"
  884.     beginsetup cvbool {
  885.         /beginsetup false hidebool
  886.         fd ( end %PROLOGUE\n) writestring
  887.         fd (\n%%EndSetup\n%%Page: 1 1\n) writestring
  888.         fd (%%PageFonts: (atend)\n) writestring
  889.         fd (%%PageBoundingBox: (atend)\n) writestring
  890.        fd (%%BeginPageSetup\n PROLOGUE begin\n%%EndPageSetup\n) writestring
  891.         fd (1 BEGINPAGE\n) writestring
  892.         /begunpage true hidebool
  893.         /fontcount 0 store
  894.     }{ %else
  895.         lastshowpage cvbool { %if
  896.         /lastshowpage false hidebool
  897.         /fontcount 0 store
  898.         writeNL (%%Page: ) wout
  899.         trace { (page: ) rprint pagecount cvnum == flush } if
  900.         /pagecount pagecount cvnum 1 add hideval
  901.         pagecount cvnum dup writenum writenum writeNL
  902.         (%%PageFonts: (atend)) writeop
  903.         (%%PageBoundingBox: (atend)) writeop
  904.         (%%BeginPageSetup) writeop
  905.         ( PROLOGUE begin) writeop
  906.         (%%EndPageSetup) writeop
  907.         pagecount cvnum scratch cvs wout ( BEGINPAGE\n) wout
  908.         /begunpage true hidebool
  909.         invalidatefonts
  910.         } if
  911.     } ifelse
  912.     } bdef
  913.     /writenamearray {        % [ /name ... ] :
  914.     fd ([) writestring
  915.     /indentlevel ++ fd (\n) writestring indent
  916.     /CNT 1 store
  917.     %| maintain CNT to count bytes.  wrap lines at a reasonable
  918.     %| place when writing out character names, to avoid long lines
  919.     { %forall
  920.         fd (/) writestring
  921.         dup type /nametype eq { scratch cvs }{ pop (.notdef) } ifelse
  922. %%%        dup length 1 eq {
  923. %%%        dup 0 get dup 32 lt exch 128 gt { pop ( ) } if
  924. %%%        } if
  925.         dup  length 1 add CNT add /CNT exch store  fd exch writestring
  926.         CNT 60 ge { /CNT 1 store fd (\n) writestring indent } if
  927.     } forall
  928.     /indentlevel -- fd (\n) writestring indent fd (]) writestring
  929.     } bdef
  930.     /writediffencoding {    % [ 32/name 37/etc ... ] :
  931.     fd ([) writestring
  932.     /indentlevel ++ fd (\n) writestring indent
  933.     /CNT 1 store
  934.     %| maintain CNT to count bytes.  wrap lines at a reasonable
  935.     %| place when writing out character names, to avoid long lines
  936.     { %forall
  937.         dup type /integertype eq { %ifelse
  938.         fd (\040) writestring
  939.         scratch cvs fd exch writestring /CNT CNT 4 add store
  940.         }{ %else
  941.         fd (/) writestring
  942.         dup type /nametype eq { scratch cvs }{ pop (.notdef) } ifelse
  943.         dup  length 1 add CNT add /CNT exch store  fd exch writestring
  944.         } ifelse
  945.         CNT 60 ge { /CNT 1 store fd (\n) writestring indent } if
  946.     } forall
  947.     /indentlevel -- fd (\n) writestring indent fd (]) writestring
  948.     } bdef
  949.  
  950.   % write numbers in various formats:
  951.  
  952.     /thruCTM { CTM transform } bdef
  953.     /dthruCTM { CTM dtransform } bdef
  954.     /XthruCTM { %def
  955.     dup CTM dtransform
  956.     rot not { pop }{ %else
  957.         2 copy gt { pop }{ exch pop } ifelse
  958.     } ifelse
  959.     } bdef
  960.  
  961.     /*writestring { %def
  962.     writestring fd *flushfile
  963.     } bdef
  964.     /shave { %def
  965.       % eliminate significant digits beyond .0001; compensate for roundoff
  966.     dup type /realtype eq { %if
  967.         10000 mul round 10000 div
  968.     } if
  969.     } bdef
  970.     /writenum { % def        % num :
  971.     dup abs 0.001 le { pop 0 } if        % --> 0
  972.     dup dup cvi eq { cvi } if
  973.     fd exch scratch cvs writestring _space
  974.     } bdef
  975.     /writeprecisenum { % def        % num :
  976.     fd exch scratch cvs writestring _space
  977.     } bdef
  978.     /writeXnum { % def        % num :
  979.     CTM 0 get mul writenum
  980.     } bdef
  981.     /writeYnum { % def        % num :
  982.     CTM 3 get mul writenum
  983.     } bdef
  984.     /writeTpair { % def        % num1 num2 :
  985.     thruCTM exch
  986.     writenum writenum
  987.     } bdef
  988.     /writepair { % def        % num1 num2 :
  989.     exch writenum writenum
  990.     } bdef
  991.     /writenumarray {        % [ nums ] :
  992.     fd ([) writestring
  993.     { writenum } forall
  994.     fd (] ) writestring
  995.     } bdef
  996.  
  997.   % write out names and strings:
  998.     /rprint /print load def
  999.     /r= /= load def
  1000. %    /print { fd exch writestring } bind def
  1001. %    /= { scratch cvs fd exch writestring writeNL } bind def
  1002.  
  1003.     /writeNL { fd (\n) writestring } bdef
  1004.     /_space { fd (\040) writestring } bdef
  1005.     /wout { % def        % (string) :
  1006.      fd exch writestring
  1007.      flushout { fd *flushfile } if
  1008.     } bdef
  1009.     /writestr { % def        % (string) :
  1010.     fd exch writestring _space
  1011.     } bdef
  1012.     /writeop { %def        % (string) :
  1013.     fd exch writestring writeNL
  1014.     } bdef
  1015.     /writePSstring { % def    % (string) :
  1016.     fd (\() writestring dup length 75 gt exch
  1017.     wordfix fd (\) ) writestring { writeNL } if % if length > 75 bytes
  1018.     } bdef
  1019.     % formathexstring, thanks to Anders Blomdell
  1020.     %    file string linelength formathexstring
  1021.     /formathexstring { %def
  1022.     hexformat 2 idiv 1 index length
  1023.     0 2 index 2 index { %for
  1024.         dup 3 index add 2 index lt { %ifelse
  1025.         2 index
  1026.         }{ %else
  1027.         dup 2 index sub neg
  1028.         } ifelse
  1029.         4 index 3 1 roll getinterval
  1030.         4 index exch writehexstring writeNL
  1031.     } for
  1032.     pop pop pop pop
  1033.     } bdef
  1034.     /writename { % def        % name :
  1035.     scratch cvs fd exch writestring  _space
  1036.     } bdef
  1037.     /writeRname { % def        % name :
  1038.     (/) wout scratch cvs wout (R ) wout
  1039.     } bdef
  1040.     /checkusernames { %def    % array :
  1041.     { % forall
  1042.         dup type /nametype ne { pop }{ %ifelse
  1043.         dup systemdict exch known { pop }{ % ifelse
  1044.             dup xcheck not { pop }{ %ifelse
  1045.             dup unames exch known { pop }{ %ifelse
  1046.                 dup where not { %ifelse
  1047.                 dup unames exch true put
  1048.                 pop % assume it's taken care of
  1049.                 }{ %else
  1050.                 pop dup load dup type /arraytype eq
  1051.                 1 index type /packedarraytype eq or
  1052.                   { checkusernames }{ pop } ifelse
  1053.                 indent (userdict /) wout dup writename
  1054.                 dup unames exch true put
  1055.                 load writeANY
  1056.                 (put) writeop indent
  1057.                 } ifelse
  1058.             } ifelse
  1059.             } ifelse
  1060.         } ifelse
  1061.         } ifelse
  1062.     } forall
  1063.     } bdef
  1064.     /arrayusernames { %def
  1065.     dup type /arraytype eq 1 index type /packedarraytype eq or { %ifelse
  1066.         dup checkusernames
  1067.         { arrayusernames } forall
  1068.     }{ pop } ifelse
  1069.     } bdef
  1070.     /writeproc { %def
  1071.     ({) writestr
  1072.     insideproc exch /insideproc true store
  1073.     dup type /arraytype eq 1 index type /packedarraytype eq or { % ifelse
  1074.         dup length 20 lt { %ifelse
  1075.         { writeANY } forall
  1076.         }{ %else
  1077.         writeNL /indentlevel ++ indent
  1078.         { writeANY writeNL indent } forall
  1079.         /indentlevel -- writeNL indent
  1080.         } ifelse
  1081.     }{ %else
  1082.         writename
  1083.     } ifelse
  1084.     /insideproc exch store
  1085.     (} ) writestr
  1086.     } bdef
  1087.     /typedict 12 dict def
  1088.     typedict begin
  1089.     /stringtype {
  1090.         dup 0 get 0 eq 1 index dup length 1 sub get 0 eq or {
  1091.         (<) wout fd exch formathexstring (> ) wout
  1092.         }{ writePSstring } ifelse
  1093.     } bdef
  1094.     /arraytype { %def
  1095.         % dup checkusernames
  1096.         dup xcheck { %ifelse
  1097.         writeproc
  1098.         }{ %else
  1099.         /CNT 1 store
  1100.         dup length 20 lt { %ifelse
  1101.             ([ ) wout { writeANY } forall (] ) wout
  1102.         }{ %else
  1103.             ([) writeop /indentlevel ++
  1104.             { indent writeANY writeNL } forall
  1105.             /indentlevel -- indent (] ) wout
  1106.         } ifelse
  1107.         } ifelse
  1108.     } bdef
  1109.     /packedarraytype /arraytype load def
  1110.     /dicttype { %def
  1111.               % safety: 1 add (needed for User Fonts)
  1112.         dup maxlength 1 add writenum (dict begin) writeop indent
  1113.         { %forall
  1114.         exch writeANY writeANY (def ) writeop indent
  1115.         } forall (currentdict end ) wout
  1116.     } bdef
  1117.     /integertype { writenum } def
  1118.     /realtype { writeprecisenum } def
  1119.     /nulltype { pop (null ) wout } def
  1120.     /operatortype { %def
  1121.         insideproc { %ifelse
  1122.         writename
  1123.         }{ %else
  1124.         (/) wout writename (load) writestr
  1125.         } ifelse
  1126.     } bdef
  1127.     /nametype { %def
  1128.         dup xcheck not { (/) wout dup unames exch true put } if
  1129.         writename
  1130.     } bdef
  1131.     end % typedict
  1132.     /writeANY { %def
  1133.     dup type dup typedict exch known { %ifelse
  1134.         typedict exch get exec
  1135.     }{ %else
  1136.         pop writename
  1137.     } ifelse
  1138.     } bdef
  1139.     % The following writes an escaped string that may contain special chars.
  1140.     % It regenerates the (\035string) notation.
  1141.     /wordfix { %def        % (string) :
  1142.     (\() search { %ifelse
  1143.         rparenfix (\\\() wout pop wordfix
  1144.     }{ rparenfix } ifelse
  1145.     } bdef
  1146.     /rparenfix { %def
  1147.     (\)) search { %ifelse
  1148.         binaryfix (\\\)) wout pop rparenfix
  1149.     }{ binaryfix } ifelse
  1150.     } bdef
  1151.     /str1 1 string def
  1152.     /longstr 1028 string def
  1153.     /writetomark { %def
  1154.     counttomark -1 0 { %for
  1155.         longstr exch exch put
  1156.     } for
  1157.     } bdef
  1158.     /binaryfix { %def
  1159.     dup false exch { %forall
  1160.         dup 128 gt 1 index 32 lt or { %ifelse
  1161.         str1 exch 0 exch put pop true exit
  1162.         }{ pop } ifelse
  1163.     } forall
  1164.     { %ifelse    % depending on whether binary num was found
  1165.         str1 search {
  1166.         quotefix        % string previous to binary num
  1167.         (\\) wout        % the backslash
  1168.         0 get dup 8 eq {
  1169.             pop (b) wout
  1170.         }{ %else
  1171.             dup 10 eq {
  1172.             pop (n) wout
  1173.             }{ %else
  1174.             % write binary char as octal: \008
  1175.             8 scratch cvrs
  1176.             dup length 3 exch sub { (0) wout } repeat wout
  1177.             } ifelse
  1178.         } ifelse
  1179.         binaryfix        % recurse on rest of string
  1180.         }{
  1181.         (ERROR: search lied in "binaryfix".) r= flush stop
  1182.         } ifelse
  1183.     }{ quotefix } ifelse
  1184.     } bdef
  1185.     /quotefix { %def
  1186.     (\\) search {  %ifelse
  1187.         wout (\\\\) wout pop quotefix
  1188.     }{ wout } ifelse
  1189.     } bdef
  1190.  
  1191. end %adobe_distill
  1192. /setpacking where { pop setpacking } if
  1193. %%EndProcSet distill 1.0 0
  1194.  
  1195. %%BeginProcSet: distill_graphicstate 1.0 0
  1196. % we don't want packed arrays for all these matrices; set packing later
  1197. /adobe_distill dup where { pop pop }{ 165 200 add dict def } ifelse
  1198. adobe_distill begin
  1199.  
  1200.     trylandscape { %if
  1201.     0 612 translate -90 rotate
  1202.     } if
  1203.   % define a bunch of state variables, then use "store" subsequently
  1204.   % to write into them (to avoid currentdict problems).
  1205.     /mtx matrix def
  1206.     /tmpmtx matrix def
  1207.     /fontmtx matrix def
  1208.     /curfontmtx matrix def
  1209.     /CTM matrix currentmatrix def
  1210.     /normalCTM tmpmtx currentmatrix matrix invertmatrix def
  1211.     /compareCTM matrix currentmatrix def
  1212.     /newCTM matrix def
  1213.     /mtx1 0 def
  1214.     /mtx2 0 def
  1215.     /$normalize {
  1216.     dup tmpmtx copy normalCTM 3 -1 roll concatmatrix
  1217.     } bind def
  1218.     /rot false def
  1219.     /gray currentgray def
  1220.     currentcmykcolor
  1221.     /colK exch def /colY exch def /colM exch def /colC exch def
  1222.     currentrgbcolor
  1223.     /colB exch def /colG exch def /colR exch def
  1224.     /linewidth currentlinewidth def
  1225.     /linecap currentlinecap def
  1226.     /linejoin currentlinejoin def
  1227.     /miterlimit currentmiterlimit def
  1228.     /screenang null def
  1229.     /screenfreq null def
  1230.     /screenproc null def
  1231.     /closed false def
  1232.     currentdash /dashoff exch def /dasharray exch def
  1233.     /pointX -1 def /pointY -1 def
  1234.     /initfontscale { 1 0 0 1 0 0 $fontscale astore pop } bind def
  1235.     /$fontscale matrix  def
  1236.     /0a 0 def /0b 0 def
  1237.     /X1 0 def /X2 0 def
  1238.     /origfontname null def
  1239.     /currfontdict null def
  1240.     /definefontname null def
  1241.     /tempfontname /Courier def
  1242. %    /defaultfontname substitutefonts { /Courier }{ /Unknown } ifelse def
  1243.     /defaultfontname {
  1244.     /FontType where { %ifelse
  1245.         pop FontType 3 eq {
  1246.         FontInfo /realname get
  1247.         }{ substitutefonts { /Courier }{ /Unknown } ifelse } ifelse
  1248.     }{ %else
  1249.         substitutefonts { /Courier }{ /Unknown } ifelse
  1250.     } ifelse
  1251.     } def
  1252.     /ischarpath false def
  1253.     /currpath newpath hashpath def
  1254.     /pathstr () def
  1255.     /pathbool false def
  1256.     /pathX 0 def /pathY 0 def
  1257.     /lineX 0 def /lineY 0 def
  1258.     /closeX 0 def /closeY 0 def
  1259.     /lcount 0 def /rcount 0 def
  1260.     /REPEAT_LINETO_THRESHOLD 20 def    % point at which repeat loop is used
  1261.     /currX -1 def /currY -1 def
  1262.     /diffX 0 def
  1263.     /gstates 0 def
  1264.     /charpathgstate 0 def
  1265.     /CNT 0 def
  1266.     /showX null def /showY null def
  1267.     /currfont currentfont def
  1268.     newpath /cliphash clippath hashpath def newpath
  1269.     /?simplepath false def
  1270.     /simplepath [ 0 0 0 0 ] def
  1271.  
  1272. /setpacking where { pop currentpacking true setpacking } if
  1273.  
  1274.     /matrixeq { %def        % compares two matrices
  1275.     /mtx2 exch store
  1276.     /mtx1 exch store
  1277.     0 1 5 { %for
  1278.         dup mtx1 exch get
  1279.         exch mtx2 exch get eq
  1280.     } for
  1281.     5 { and } repeat
  1282.     } bdef
  1283.     % begin eqarray AB 890420 (thanks to Anders Blomdell)
  1284.     %   array1 array2 eqarray bool
  1285.     /arrayeq {
  1286.       % if they're equal, they're equal: simplicity first...
  1287.     2 copy eq { pop pop true }{ %ifelse
  1288.         % next check their lengths, for trivial eq/ne:
  1289.         2 copy length exch length eq { %ifelse
  1290.         % We now have to compare all elements
  1291.         true                % arr arr true
  1292.         0 1 3 index length 1 sub    % arr arr true 0 1 length-1
  1293.         {                % arr arr bool index
  1294.           3 index 1 index get        % arr arr bool index val1
  1295.           3 index 2 index get        % arr arr bool index val1 val2
  1296.           eq exch pop and        % arr arr bool
  1297.         } for
  1298.         exch pop exch pop
  1299.         }{ pop pop false } ifelse
  1300.     } ifelse
  1301.     } bdef
  1302.     /arrayne {
  1303.       arrayeq not
  1304.     } bdef
  1305.  
  1306.   % procedure definitions for state machinery ---------------
  1307.  
  1308.     /initgstate { %def
  1309.     gsave
  1310.         initgraphics
  1311.         trylandscape { %if
  1312.         0 612 translate -90 rotate
  1313.         } if
  1314.         /CTM mtx currentmatrix $normalize store
  1315.         tmpmtx currentmatrix compareCTM matrixeq not {
  1316.         .345 dup 0 dtransform pop 0 idtransform
  1317.         pop ne dup /rot exch store not optimize and /optim exch store
  1318.         } if
  1319.         compareCTM currentmatrix pop
  1320.         /gray currentgray store
  1321.         currentcmykcolor
  1322.         /colK exch store /colY exch store
  1323.         /colM exch store /colC exch store
  1324.         currentrgbcolor
  1325.         /colB exch def /colG exch def /colR exch def
  1326.         /linewidth currentlinewidth XthruCTM store
  1327.         /linecap currentlinecap store
  1328.         /linejoin currentlinejoin store
  1329.         /miterlimit currentmiterlimit store
  1330.         currentdash /dashoff exch store /dasharray exch store
  1331.         /origfontname /InvalidFont store
  1332.         /definefontname /InvalidFont store
  1333.         initfontscale
  1334.         /currfontdict currentfont store
  1335.         currentscreen
  1336.         /screenproc exch store
  1337.         /screenang exch store
  1338.         /screenfreq exch store
  1339.         newpath
  1340.         /cliphash clippath hashpath store
  1341.         newpath
  1342.     grestore
  1343.     } bdef % initgstate
  1344.     /forcegstate { %def
  1345.     % after save & restore, you may have to explicitly "undo" anything
  1346.     % that was done within the saved context.  Since save & restore
  1347.     % affect all our state variables, we dump anything that is different
  1348.     % from the default graphics state:
  1349.     /CTM [1.01 0 1.01 0 .5 .5] store
  1350.     /compareCTM [1.01 0 1.01 0 .5 .5] store
  1351.     initfontscale
  1352.     /currfontdict null store
  1353.     /gray null store
  1354.     /colC null store
  1355.     /colR null store
  1356.     % checkgstate % fontstate
  1357.     currentfont null ne { % if
  1358.         currentfont dup /FontInfo known { %ifelse
  1359.         /FontInfo get dup /pleasemap known { %ifelse
  1360.             begin /pleasemap true hidebool end
  1361.         }{ pop } ifelse
  1362.         }{ pop } ifelse
  1363.     } if
  1364.     } bdef % initgstate
  1365.     /checkgstate { %def
  1366.     graphicstate
  1367.     fontstate
  1368.     } def %checkgstate
  1369.     /checkCTM { %def
  1370.     tmpmtx currentmatrix compareCTM matrixeq not {
  1371.         % /CTM mtx currentmatrix $normalize store
  1372.         CTM currentmatrix $normalize pop
  1373.         compareCTM currentmatrix $normalize pop
  1374.         .345 dup 0 dtransform pop 0 idtransform
  1375.         pop ne dup /rot exch store not optimize and /optim exch store
  1376.     } if
  1377.     } bdef
  1378.     /generalstate { %def
  1379.     stackptr 0 ne { stackshow } if
  1380.     /lastshow false store
  1381.     checkCTM
  1382.     } bdef % generalstate
  1383.     /colorstate { %def
  1384.     colormodel /CMYK eq { %ifelse
  1385.         mark currentcmykcolor
  1386.         colC colM colY colK 4 { %repeat
  1387.         dup 5 index ne 10 1 roll 8 1 roll
  1388.         } repeat
  1389.         cleartomark or or or {
  1390.         currentcmykcolor
  1391.         /colK exch store /colY exch store
  1392.         /colM exch store /colC exch store
  1393.         colC 0 eq colM 0 eq colY 0 eq and and not { %ifelse % COLOR
  1394.             colC writenum colM writenum colY writenum colK writenum
  1395.             (CMYK) writeop
  1396.         }{ %else                        % GRAY
  1397.             1 colK sub shave writenum (g) writeop
  1398.         } ifelse
  1399.         } if
  1400.     }{ %else
  1401.         mark currentrgbcolor
  1402.         colR colG colB 3 { %repeat
  1403.         dup 4 index ne 8 1 roll 6 1 roll
  1404.         } repeat
  1405.         cleartomark or or {
  1406.         currentrgbcolor
  1407.         /colB exch store /colG exch store /colR exch store
  1408.         colR 1 eq colG 1 eq colB 1 eq and and { %ifelse
  1409.             (1 g) writeop
  1410.         }{ %else
  1411.             colR 0 eq colG 0 eq colB 0 eq and and { %ifelse
  1412.             (0 g) writeop
  1413.             }{ %else
  1414.             colR writenum colG writenum colB writenum
  1415.             (RGB) writeop
  1416.             } ifelse
  1417.         } ifelse
  1418.         } if
  1419.     } ifelse
  1420.     } bdef % colorstate
  1421.     /registerfont { %def
  1422.     % dup =string cvs print ( registered ) print 1 index == flush
  1423.     dup cachedir exch 20 dict put    % allow 20 point sizes
  1424.     cachedir exch get        % ptsize dict
  1425.     exch fontcount put
  1426.     } bdef
  1427.     /addfontsize { %def
  1428.     % dup =string cvs print ( point size ) print 1 index == flush
  1429.     cachedir exch get
  1430.     exch fontcount put
  1431.     } bdef
  1432.  
  1433.     /fontstate { %def
  1434.       currentfont null eq not    { %if
  1435.     currentfont dup /ScaleMatrix known not { pop }{ %ifelse
  1436.         begin
  1437.          % determine if anything has changed:
  1438.         tmpmtx currentmatrix compareCTM matrixeq not
  1439.         currfontdict currentfont ne or
  1440.         ScaleMatrix CTM tmpmtx concatmatrix $fontscale matrixeq not or
  1441.         { %if
  1442.           % get and set new font names
  1443.             /origfontname
  1444.             /FontInfo where { %ifelse
  1445.                 pop FontInfo /realname known
  1446.                 { FontInfo /realname get }{ % ifelse
  1447.                 currentdict /FontName known { FontName }{
  1448.                     defaultfontname
  1449.                 } ifelse
  1450.                 } ifelse
  1451.             }{ %else
  1452.                 currentdict /FontName known { FontName }{
  1453.                 defaultfontname
  1454.                 } ifelse
  1455.             } ifelse
  1456.             store
  1457.             /definefontname
  1458.             currentdict /FontName known { FontName }{
  1459.                 origfontname
  1460.             } ifelse
  1461.             FontDirectory { %forall
  1462.                 currentdict eq
  1463.                 { exch pop exit }
  1464.                 { pop } ifelse
  1465.             } forall
  1466.             store
  1467.             origfontname hidefontname
  1468.          % check for font reencoding:
  1469.          % The current font is the one required in the distilled
  1470.          % program.  If it is a reeconded font, we must generate
  1471.          % a call to "REMAP", but at the same time let's mark it
  1472.          % so we don't generate too may "REMAP" calls.
  1473.  
  1474.             checksetup generalstate colorstate
  1475.          % worry about reencoding:
  1476.             /FontInfo where { %ifelse
  1477.             pop FontInfo /pleasemap known { %ifelse
  1478.                 FontInfo /pleasemap get cvbool
  1479.             }{ %else
  1480.                 false  % evidently has not been reencoded...
  1481.             } ifelse % leaves a boolean
  1482.             }{ false } ifelse
  1483.             { % if remapping has not been done yet:
  1484.             Encoding hashencoding
  1485.             origfontname findfont /Encoding get hashencoding
  1486.             ne { %ifelse
  1487.                 Encoding hashencoding
  1488.                 STDvec cvnum eq { %ifelse
  1489.                 (stdvec) writestr
  1490.                 origfontname writeRname
  1491.                 origfontname (/) wout writename
  1492.                 ( REMAP) writeop
  1493.                 }{ %else
  1494.                   Encoding hashencoding PAGEvec cvnum eq {
  1495.                   (pagevec) writestr
  1496.                   origfontname writeRname
  1497.                   origfontname (/) wout writename
  1498.                   ( REMAP) writeop
  1499.                   }{ %else
  1500.                   origfontname findfont /Encoding get Encoding
  1501.                   diffencoding writediffencoding
  1502.                   origfontname writeRname
  1503.                   origfontname (/) wout writename
  1504.                   ( RECODE) writeop
  1505.                   } ifelse
  1506.                 } ifelse
  1507.                 /FontInfo where { %if
  1508.                 pop FontInfo /pleasemap known { %if
  1509.                     FontInfo begin
  1510.                         /pleasemap false hidebool
  1511.                     end
  1512.                 } if
  1513.                 } if
  1514.             } if
  1515.             } if % /pleasemap
  1516.          % check font scale change:
  1517.          % This stuff is absolutely horrible....
  1518.             ScaleMatrix CTM $fontscale concatmatrix
  1519.              aload pop                % Xscale 0a 0b Yscale 0 0
  1520.             pop pop 3 1 roll            % X Y 0b 0a
  1521.            % if 0a and 0b are really both 0 ...
  1522.            % and X Y are equal and positive, then you can use
  1523.            % "scalefont", else you have to use "makefont"
  1524.             /0a exch store /0b exch store
  1525.             /X1 exch store /X2 exch store
  1526.              X1 X2            % leave on stack
  1527.             0a 0b eq 0b 0 eq and    % make sure 0's are 0
  1528.              X1 X2 EQ and        % X1 and X2 are equal
  1529.              X1 dup abs eq X2 dup abs eq and    % and positive
  1530.             and
  1531.             { %ifelse
  1532.             pop dup dup round EQ { round } if
  1533.              % if you find it in the "font dict cache"....
  1534.             cachedir definefontname known { %ifelse
  1535.                 cachedir definefontname get dup 2 index known {
  1536.                 exch get (F) wout writenum
  1537.                 (F) writeop
  1538.                 }{ %else
  1539.                 pop
  1540.                 /fontcount ++
  1541.                 dup definefontname addfontsize
  1542.                 (/F) wout fontcount writenum %+ cvnum writenum
  1543.                 origfontname
  1544.                 /FontInfo where { %ifelse
  1545.                     pop FontInfo /pleasemap known { %ifelse
  1546.                     FontInfo /pleasemap get cvbool
  1547.                     }{ false } ifelse % leaves a boolean
  1548.                 }{ false } ifelse
  1549.                 Encoding hashencoding
  1550.                 origfontname findfont /Encoding get
  1551.                 hashencoding ne and
  1552.                 { %ifelse
  1553.                     writeRname
  1554.                 }{ (/) wout writename } ifelse
  1555.                 writenum % point size
  1556.                 (DF) writeop
  1557.                 } ifelse
  1558.             }{ %else if you DON'T find the name in the cache
  1559.                 cachefonts { %if
  1560.                 /fontcount ++
  1561.                 dup definefontname registerfont
  1562.                 (/F) wout fontcount writenum
  1563.                 } if
  1564.                 origfontname  % either "FontName" or "FontNameR"
  1565.                 /FontInfo where { %ifelse
  1566.                 pop FontInfo /pleasemap known { %ifelse
  1567.                     FontInfo /pleasemap get cvbool not
  1568.                 }{ false } ifelse % leaves a boolean
  1569.                 }{ false } ifelse
  1570.                 Encoding hashencoding
  1571.                 origfontname findfont /Encoding get
  1572.                 hashencoding ne and
  1573.                 { %ifelse
  1574.                 writeRname
  1575.                 }{ (/) wout writename } ifelse
  1576.                 writenum % point size
  1577.                 cachefonts { (DF) }{ (FF) } ifelse writeop
  1578.             } ifelse
  1579.             }{ %else
  1580.              % need either "makefont" or rotated coordinate system
  1581.             % careful.... there's still stuff on the stack.
  1582.             origfontname
  1583.             /FontInfo where {
  1584.                 pop FontInfo /pleasemap known
  1585.             }{ false } ifelse { %ifelse
  1586.                 writeRname
  1587.             }{ (/) wout writename } ifelse
  1588.             pop pop $fontscale aload pop curfontmtx astore
  1589.             dup 4 ScaleMatrix 4 get put
  1590.             dup 5 ScaleMatrix 5 get put  % no translate
  1591.             writenumarray
  1592.             (MF) writeop
  1593.             } ifelse
  1594.             /currfontdict currentfont store
  1595.         } if % anything has changed
  1596.         end
  1597.     } ifelse
  1598.     beginsetup cvbool not {
  1599.         generalstate
  1600.         colorstate
  1601.     } if
  1602.       } if
  1603.     } bdef %fontstate
  1604.  
  1605.     /graphicstate { %def
  1606.     checksetup
  1607.     generalstate
  1608.     colorstate
  1609.     linewidth currentlinewidth XthruCTM ne {
  1610.         /linewidth currentlinewidth XthruCTM store
  1611.         linewidth shave writenum (w) writeop
  1612.     } if
  1613.     linecap currentlinecap ne {
  1614.         /linecap currentlinecap store
  1615.         linecap writenum (setlinecap) writeop
  1616.     } if
  1617.     linejoin currentlinejoin ne {
  1618.         /linejoin currentlinejoin store
  1619.         linejoin writenum (j) writeop
  1620.     } if
  1621.     miterlimit currentmiterlimit ne {
  1622.         /miterlimit currentmiterlimit store
  1623.         miterlimit shave writenum (setmiterlimit) writeop
  1624.     } if
  1625.     currentdash dashoff ne exch dasharray arrayne or {
  1626.         currentdash /dashoff exch store /dasharray exch store
  1627.         fd ([) writestring
  1628.         dasharray { XthruCTM writenum } forall
  1629.         fd (] ) writestring
  1630.         dashoff XthruCTM writenum (d) writeop
  1631.     } if
  1632.     gsave
  1633.       % check clip path    % update release 12 edit 0
  1634.         newpath clippath hashpath cliphash ne { %if
  1635.         writepath
  1636.         (initclip clip newpath) writeop
  1637.         /cliphash newpath clippath hashpath store
  1638.         } if
  1639.     grestore
  1640.     currentscreen
  1641.     /screenproc load ne exch screenang ne or exch screenfreq ne or { %if
  1642.         currentscreen
  1643.         /screenproc exch store
  1644.         /screenang exch store
  1645.         /screenfreq exch store
  1646.         screenfreq writenum screenang writenum writeNL
  1647.         /screenproc load
  1648.         dup type /arraytype eq
  1649.         1 index type /packedarraytype eq or { %ifelse
  1650.         checkusernames
  1651.         }{ pop } ifelse
  1652.         /screenproc load writeproc
  1653.         (setscreen) writeop
  1654.     } if
  1655.     } bdef %graphicstate
  1656.  
  1657. end %adobe_distill
  1658. /setpacking where { pop setpacking } if
  1659. %%EndProcSet distill_graphicstate 1.0 0
  1660.  
  1661. %%BeginProcSet: distill_optimize 1.0 0
  1662. /adobe_distill dup where { pop pop }{ 165 200 add dict def } ifelse
  1663. adobe_distill begin
  1664.   % These procedures implement an optimization scheme for recognizing
  1665.   % sequences of "show" operations that could be optimized into calls
  1666.   % to "widthshow" (or just "show" with a longer string body).  In
  1667.   % order to accomplish this, we have implemented a stack to store
  1668.   % string bodies until they are flushed by a font change, a change
  1669.   % in Y coordinate, or an inter-string space that is inconsistent.
  1670.   % When comparing coordinates for equality, anything with the given
  1671.   % tolerance is accepted as being equal (to combat roundoff error).
  1672.     /tolerance .05 ifnotdef
  1673.     /EQ { sub abs tolerance le } bdef
  1674.     /stack 250 array def
  1675.     /stackptr 0 def
  1676. /setpacking where { pop currentpacking true setpacking } if
  1677.     /push { %def
  1678.     stackptr 0 eq { % if
  1679.         currentpoint thruCTM
  1680.         /showY exch store /showX exch store
  1681.     } if
  1682.     /stackptr stackptr 1 add store
  1683.       stackptr 249 ge { (STACK OVERFLOW!) r= flush exit } if
  1684.     stack stackptr 3 -1 roll put
  1685.     } bdef
  1686.     /pull { %def
  1687.     stack stackptr get
  1688.     /stackptr stackptr dup 0 gt { 1 sub } if store
  1689.     } bdef
  1690.  
  1691.     /*save systemdict /save get def
  1692.     /save { % def
  1693.     stackshow    % in case there's anything pending....
  1694.     *save
  1695.     } bdef
  1696.  
  1697.     /*restore systemdict /restore get def
  1698.     /restore { % def
  1699.     % after save & restore, you may have to explicitly "undo" anything
  1700.     % that was done within the saved context.  Since save & restore
  1701.     % affect all distillery state variables, we dump anything different
  1702.     % from the default graphics state:
  1703.     stackshow    % in case there's anything pending....
  1704.       currentCOLOR        % 5,6,7,8
  1705.       currentlinecap    % 4
  1706.       currentlinewidth    % 3
  1707.       currentmiterlimit    % 2
  1708.       currentlinejoin    % 1
  1709.         9 -1 roll *restore
  1710.       setlinejoin        % 1
  1711.       setmiterlimit        % 2
  1712.       setlinewidth        % 3
  1713.       setlinecap        % 4
  1714.       setCOLOR        % 5,6,7,8
  1715.     forcegstate % checkgstate %graphicstate
  1716.     } bdef
  1717.  
  1718.     /stackshow { %def
  1719.     stackptr 0 ne { %if
  1720.         messages {
  1721.         (stackshow: ) d=
  1722.         1 1 stackptr { (  ) pr= stack exch get == } for
  1723.         } if
  1724.         stackptr 1 eq { %ifelse
  1725.         %- if there is only one string, use "show":
  1726.         pull writePSstring
  1727.         showX showY writepair (T) writeop
  1728.         }{ %else
  1729.         %- otherwise, build single string (with \b to use W):
  1730.         diffX 0 EQ not { % if
  1731.             gsave        % figure out widthshow value
  1732.             currfont setfont
  1733.             diffX (\b) stringwidth CTM dtransform pop sub
  1734.             grestore
  1735.             writenum (0) writestr (\b) 0 get writenum
  1736.             (\\b)    % padding character
  1737.         }{ % else
  1738.             ()        % empty padding character
  1739.         } ifelse
  1740.         (\() wout
  1741.         1 1 stackptr 1 sub { % for
  1742.             stack exch get wordfix dup wout
  1743.         } for
  1744.         pop        % padding character
  1745.         pull wordfix
  1746.         (\)) wout % writeNL
  1747.         showX showY writepair
  1748.         %- if diffX is 0, don't use "widthshow":
  1749.         diffX 0 EQ { (T) }{ (W) } ifelse writeop
  1750.         } ifelse
  1751.         /stackptr 0 store
  1752.     } if
  1753.     } bdef
  1754.  
  1755.     /setcurrpoint { %def
  1756.     currentpoint thruCTM
  1757.     /currY exch store /currX exch store
  1758.     } bdef % setcurrpoint
  1759.  
  1760. end %adobe_distill
  1761. /setpacking where { pop setpacking } if
  1762. %%EndProcSet distill_optimize 1.0 0
  1763.  
  1764. %%BeginProcSet: distill_paintops 1.0 0
  1765. /setpacking where { pop currentpacking true setpacking } if
  1766. /adobe_distill dup where { pop pop }{ 165 200 add dict def } ifelse
  1767. adobe_distill begin
  1768.  
  1769.   % text operators
  1770.     /sameYcoords { %def
  1771.       % this is pulled out of the "show" proc for readability; it is
  1772.       % not used anywhere else
  1773.     currentfont currfont ne { %ifelse
  1774.         stackshow fontstate push
  1775.     }{ %else
  1776.         currentpoint thruCTM pop
  1777.         currX sub dup diffX EQ { %ifelse
  1778.         pop     % dup'ed value
  1779.         push
  1780.         }{ %else
  1781.         diffX -1 eq { %ifelse
  1782.             /diffX exch store push
  1783.         }{ % else
  1784.             pop stackshow fontstate
  1785.             /diffX -1 store push
  1786.         } ifelse
  1787.         } ifelse
  1788.     } ifelse
  1789.     } bdef
  1790.  
  1791.     /*stringwidth /stringwidth load def
  1792.     /stringwidth { %def
  1793.     false setdistill *stringwidth true setdistill
  1794.     } bdef
  1795.     /show { %def
  1796.     checkCTM currentpoint thruCTM ?box
  1797.     optim { %ifelse
  1798.         dup length 0 eq { pop } { %ifelse
  1799.         dup            % save string for use at the end
  1800.         lastshow not { %ifelse
  1801.             stackshow fontstate
  1802.             /currfont currentfont store
  1803.             push
  1804.             /diffX -1 store
  1805.         }{ % else
  1806.           % don't optimize if matrix is different...
  1807.             tmpmtx currentmatrix compareCTM matrixeq
  1808.             currentpoint thruCTM exch pop
  1809.             currY eq and { %ifelse        Y = Y
  1810.             sameYcoords
  1811.             }{ %else currY ne
  1812.             stackshow    % flush the pending show stack
  1813.             fontstate
  1814.             push        % the string (and set showX, showY)
  1815.             /diffX -1 store
  1816.             } ifelse
  1817.             /currfont currentfont store
  1818.         } ifelse %lastshow
  1819.         currentfont dup null ne { /FontType known }{ pop false } ifelse
  1820.         {    %gcr Fri May  5 15:22:16 1989
  1821.             currentfont /FontType get 3 eq {
  1822.             false setdistill show true setdistill
  1823.             }{ show } ifelse
  1824.         }{ false setdistill show true setdistill } ifelse
  1825.         setcurrpoint
  1826.         /lastshow true store
  1827.         } ifelse % if length is not 0
  1828.     }{ % else
  1829.         dup length 0 eq { pop } { %ifelse
  1830.         fontstate
  1831.         dup writePSstring currentpoint writeTpair
  1832.         (T) writeop
  1833.         currentfont dup null ne { /FontType known }{ pop false } ifelse
  1834.         {    %gcr Fri May  5 15:22:45 1989
  1835.             currentfont /FontType get 3 eq {
  1836.             false setdistill show true setdistill
  1837.             }{ show } ifelse
  1838.         }{ false setdistill show true setdistill } ifelse
  1839.         } ifelse % if operand is not null string
  1840.     } ifelse
  1841.     currentpoint thruCTM ?box
  1842.     } bdef
  1843.  
  1844.     /widthshow { %def
  1845.     checkCTM currentpoint thruCTM ?box
  1846.     optim { %ifelse
  1847.         dup length 0 eq { 4{pop}repeat } { %ifelse
  1848.         4 copy pop pop
  1849.         1 index EQ exch 0.0 EQ and { % ifelse
  1850.             fontstate
  1851.             4 1 roll pop pop pop
  1852.             show    % make sure it's not "bound"
  1853.         }{ %else
  1854.             fontstate
  1855.             4 copy
  1856.             4 2 roll dthruCTM writepair %exch writeXnum writeYnum
  1857.             exch writenum writePSstring currentpoint writeTpair
  1858.             (W) writeop
  1859.             currentfont dup null ne {
  1860.             /FontType known
  1861.             }{ pop false } ifelse
  1862.             { %ifelse
  1863.             currentfont /FontType get 3 eq {
  1864.                 false setdistill widthshow true setdistill
  1865.             }{ widthshow } ifelse
  1866.             }{ false setdistill widthshow true setdistill } ifelse
  1867.         } ifelse
  1868.         } ifelse
  1869.     }{ %else
  1870.         % Cx Cy char (string) widthshow
  1871.         dup length 0 eq { 4{pop}repeat } { %ifelse
  1872.         fontstate
  1873.         4 copy
  1874.         % 4 -2 roll exch writeXnum writeYnum exch writenum
  1875.         4 -2 roll dthruCTM writepair exch writenum
  1876.         writePSstring currentpoint writeTpair
  1877.         (W) writeop
  1878.         currentfont dup null ne { /FontType known }{ pop false } ifelse
  1879.         { %ifelse
  1880.             currentfont /FontType get 3 eq {
  1881.             false setdistill widthshow true setdistill
  1882.             }{ widthshow } ifelse
  1883.         }{ false setdistill widthshow true setdistill } ifelse
  1884.         } ifelse
  1885.     } ifelse
  1886.     currentpoint thruCTM ?box
  1887.     } bdef
  1888.  
  1889.     /ashow { %bdef
  1890.     checkCTM currentpoint thruCTM ?box
  1891.     optim { %ifelse
  1892.         dup length 0 eq { pop pop pop } { %ifelse
  1893.         3 copy pop
  1894.         1 index EQ exch 0.0 EQ and { % ifelse
  1895.             fontstate
  1896.             3 1 roll pop pop
  1897.             show    % make sure it's not "bound"
  1898.         }{ %else
  1899.             fontstate
  1900.             3 copy
  1901.             3 1 roll dthruCTM writepair
  1902.             writePSstring currentpoint writeTpair
  1903.             (A) writeop
  1904.             currentfont dup null ne { %ifelse
  1905.             /FontType known
  1906.             }{ pop false } ifelse
  1907.             { %ifelse
  1908.             currentfont /FontType get 3 eq {
  1909.                 false setdistill ashow true setdistill
  1910.             }{ ashow } ifelse
  1911.             }{ false setdistill ashow true setdistill } ifelse
  1912.         } ifelse
  1913.         } ifelse
  1914.     }{ %else
  1915.         dup length 0 eq { pop pop pop } { %ifelse
  1916.         fontstate
  1917.         3 copy
  1918.         3 1 roll dthruCTM writepair % exch writeXnum writeYnum
  1919.         writePSstring currentpoint writeTpair
  1920.         (A) writeop
  1921.         currentfont dup null ne { %ifelse
  1922.             /FontType known
  1923.         }{ pop false } ifelse
  1924.         { %ifelse
  1925.             currentfont /FontType get 3 eq {
  1926.             false setdistill ashow true setdistill
  1927.             }{ ashow } ifelse
  1928.         }{ false setdistill ashow true setdistill } ifelse
  1929.         } ifelse
  1930.     } ifelse
  1931.     currentpoint thruCTM ?box
  1932.     } bdef
  1933.  
  1934.     /awidthshow { %def
  1935.     % Cx Cy 32 Ax Ay (string) awidthshow
  1936.     checkCTM currentpoint thruCTM ?box
  1937.     optim { %def
  1938.         dup length 0 eq { 6{pop}repeat } { %ifelse
  1939.         fontstate
  1940.         6 copy 6 1 roll
  1941.         1 index EQ exch 0.0 EQ and { %ifelse
  1942.             4 1 roll 1 index eq exch 0.0 eq and { %leaves 32 (str)
  1943.             8 1 roll 7 { pop } repeat
  1944.             show    % make sure it's not "bound"
  1945.             }{ %else
  1946.             pop pop 3 1 roll pop pop
  1947.             widthshow    % make sure it's not "bound"
  1948.             } ifelse
  1949.         }{ %else
  1950.             pop pop pop pop 6 copy 6 -3 roll pop
  1951.             1 index EQ exch 0.0 EQ and { % ifelse
  1952.             9 3 roll 6 { pop } repeat
  1953.             ashow    % make sure it's not "bound"
  1954.             }{ %else
  1955.             pop pop pop 6 copy
  1956.             6 -2 roll dthruCTM writepair
  1957.             4 -1 roll writenum 3 1 roll dthruCTM writepair
  1958.             writePSstring currentpoint writeTpair
  1959.             (AW) writeop
  1960.             currentfont /FontType known {
  1961.                 currentfont /FontType get 3 eq {
  1962.                 false setdistill awidthshow true setdistill
  1963.                 }{ awidthshow } ifelse
  1964.             }{ false setdistill awidthshow true setdistill } ifelse
  1965.             } ifelse
  1966.         } ifelse
  1967.         } ifelse
  1968.     }{ %else
  1969.         dup length 0 eq { 6{pop}repeat } { %ifelse
  1970.         fontstate
  1971.         6 copy
  1972.         % 6 -2 roll exch writeXnum writeYnum
  1973.         % 4 -1 roll writenum 3 -1 roll writeXnum exch writeYnum
  1974.         6 -2 roll dthruCTM writepair
  1975.         4 -1 roll writenum 3 1 roll dthruCTM writepair
  1976.         writePSstring currentpoint writeTpair
  1977.         (AW) writeop
  1978.             currentfont /FontType known {
  1979.             currentfont /FontType get 3 eq {
  1980.                 false setdistill awidthshow true setdistill
  1981.             }{ awidthshow } ifelse
  1982.             }{ false setdistill awidthshow true setdistill } ifelse
  1983.         } ifelse
  1984.     } ifelse
  1985.     currentpoint thruCTM ?box
  1986.     } bdef
  1987.  
  1988.     /*kshow /kshow load def
  1989.     /kshow { %def
  1990.     (% begin: kshow) writeop
  1991.     *kshow
  1992.     (% end: kshow) writeop
  1993.     } bdef
  1994.  
  1995.    % graphics operators
  1996.     /fillguts { %def
  1997.     (starting fill) d=
  1998. %    generalstate
  1999.     graphicstate
  2000.     % do nothing for empty path!
  2001.     hashpath -1 ne { writepath } if        % watch for empty path!
  2002.     ischarpath { % if
  2003.         pathstr length 0 gt {
  2004.         pathX writenum pathY writenum (m) writeop
  2005.         pathstr writePSstring (false charpath) writeop
  2006.         } if
  2007.         gstates 0 le {
  2008.         /ischarpath false store
  2009.         /closed false store
  2010.         } if
  2011.     } if
  2012.     } bdef
  2013.  
  2014.     /fill { %def
  2015.     ?distilling cvbool { %if
  2016.         fillguts
  2017.         ?simplepath {
  2018.         simplepath aload pop
  2019.         4 2 roll writepair (moveto) writeop writepair (lineto) writeop
  2020.         /?simplepath false store
  2021.         } if
  2022.         hashpath -1 ne { (f) writeop } if
  2023.     } if
  2024.     fill
  2025.     } bdef
  2026.     /eofill { %def
  2027.     ?distilling cvbool { %if
  2028.         fillguts
  2029.         ?simplepath { %ifelse
  2030.         simplepath aload pop
  2031.         4 2 roll writepair (moveto) writeop writepair (lineto) writeop
  2032.         /?simplepath false store
  2033.         } if
  2034.         hashpath -1 ne { (eofill) writeop } if
  2035.     } if
  2036.     eofill
  2037.     } bdef
  2038.  
  2039.     /stroke { %def
  2040.     ?distilling cvbool { %if
  2041.         fillguts
  2042.         ?simplepath { %ifelse
  2043.         generalstate graphicstate
  2044.         simplepath aload pop
  2045.         4 copy 3 -1 roll eq { %ifelse
  2046.             pop pop 4 -1 roll 2 index sub writenum
  2047.             writepair (X) writeop pop
  2048.         }{ %else
  2049.             eq { %ifelse
  2050.             3 -1 roll 1 index sub writenum
  2051.             writepair (Y) writeop pop
  2052.             }{ %else
  2053.             writepair writepair (l) writeop
  2054.             } ifelse
  2055.         } ifelse
  2056.         %% writepair writepair (l) writeop
  2057.         /?simplepath false store
  2058.         }{ % else
  2059.         closed { (cp ) wout } if
  2060.         hashpath -1 ne { (s) writeop } if
  2061.         } ifelse
  2062.     } if
  2063.     stroke
  2064.     } bdef
  2065.  
  2066.     /*clip /clip load def
  2067.     /clip { %def
  2068.     ?distilling cvbool { %if
  2069.         /lastshow false store
  2070.     } if
  2071.     *clip hashpath /cliphash exch store
  2072.     } bdef
  2073.     /*eoclip /clip load def
  2074.     /eoclip { %def
  2075.     ?distilling cvbool { %if
  2076.         /lastshow false store
  2077.     } if
  2078.     *eoclip hashpath /cliphash exch store
  2079.     } bdef
  2080.     /imageguts { % def
  2081.     graphicstate
  2082.     /imageproc exch store
  2083.     /imagematrix exch store
  2084.     /imagedepth exch store
  2085.     /imageheight exch store
  2086.     /imagewidth exch store
  2087.      % set up the call to "image" in the output file:
  2088.     (/imagesave save def) writeop
  2089.     CTM writenumarray (concat) writeop
  2090.     0 0 thruCTM ?box
  2091.     imagewidth imagedepth dup type /booleantype eq { pop 1 } if
  2092.     div imageheight imagematrix itransform thruCTM ?box
  2093.     (/imagebuff) writestr
  2094.     imagedepth dup type /booleantype eq { pop 1 } if
  2095.     imagewidth mul dup dup 8 idiv 8 mul eq { %ifelse
  2096.         8 idiv
  2097.         % /pad { } store
  2098.     }{ %else
  2099.         8 idiv 1 add
  2100.         % /pad { } store
  2101.     } ifelse
  2102.     dup /imagebuffsize exch store
  2103.     writenum ( string def) writeop
  2104.      % invoke "image" with correct args in output file:
  2105.     imagewidth writenum imageheight writenum
  2106.     imagedepth (     ) cvs writestr
  2107.     imagematrix writenumarray
  2108.     writeNL
  2109.     } bdef
  2110.     /imagetrailer { %def
  2111. %       % pad with one extra scan line, for "imageflush" hack
  2112. %     save
  2113. %         imagewidth 2 mul string fd exch formathexstring writeNL
  2114. %     restore
  2115.     (%EODATA) writeop
  2116.     (%%%%%%) writeop    % for safety
  2117.     (imagesave restore) writeop
  2118.     } bdef
  2119.     /image { %def    % width height depth matrix { proc } :
  2120.     ?distilling cvbool { %ifelse
  2121.         imageguts
  2122.         ({ currentfile imagebuff readhexstring pop } IMAGE) writeop
  2123.         imagewidth imageheight imagedepth imagematrix
  2124.         { imageproc dup fd exch formathexstring writeNL } image
  2125.         imagetrailer
  2126.     }{ image } ifelse
  2127.     } bdef
  2128.     /imagemask { % def    % width height depth matrix { proc } :
  2129.     ?distilling cvbool { %ifelse
  2130.         imageguts
  2131.         ({ currentfile imagebuff readhexstring pop } IMAGEMASK) writeop
  2132.         imagewidth imageheight imagedepth imagematrix
  2133.         { imageproc dup fd exch formathexstring writeNL } imagemask
  2134.         imagetrailer
  2135.     }{ imagemask } ifelse
  2136.     } bdef
  2137.     % don't actually print the pages...   Fri Feb 17 13:13:10 1989
  2138.     % /*showpage systemdict /showpage get def
  2139.     /*showpage where { pop }{ %ifelse
  2140.     /*showpage /showpage load def
  2141.     } ifelse
  2142.     /showpage { %def
  2143.     stackshow
  2144.     pagecount cvnum scratch cvs wout ( ENDPAGE\n) wout
  2145.     (%%PageTrailer) writeop
  2146.     (%%PageFonts: ) wout
  2147.     pfontcount cvnum 0 eq { writeNL }{ %else
  2148.         pfontcount cvnum 200 lt { %ifelse
  2149.         pagefonts 0 pfontcount cvnum getinterval writeop
  2150.         }{ %else
  2151.         pagefonts (\040) search not { writeop }{ %else
  2152.             writeop    % first one without the %%+
  2153.             { %loop
  2154.             search { (%%+ ) wout writeop }{ %else
  2155.                 (\000) search { writeop pop pop }{ pop } ifelse
  2156.                 exit
  2157.             } ifelse
  2158.             } loop
  2159.         } ifelse
  2160.         } ifelse
  2161.     } ifelse
  2162.     0 1 pfontcount cvnum { pagefonts exch 0 put } for
  2163.     /pfontcount 0 hideval
  2164.     LLx 10000 eq LLy 10000 eq or URx -10000 eq URy -10000 eq or or not {
  2165.         (%%PageBoundingBox: ) wout
  2166.           LLx cvnum writenum LLy cvnum writenum
  2167.           URx cvnum writenum URy cvnum writenum writeNL
  2168.         pageBBox-docBBox
  2169.     } if
  2170.     ( end %PROLOGUE) writeop
  2171.     /LLx 10000 hideval  /LLy 10000 hideval
  2172.     /URx -10000 hideval /URy -10000 hideval
  2173.     *showpage
  2174.     /lastshowpage true hidebool
  2175.     /begunpage false hidebool
  2176.     /PAGEvec 0 hideval
  2177.     % checksetup
  2178.     } bdef
  2179.     /*pathbbox systemdict /pathbbox get def
  2180.     /pathbbox { %def
  2181.     ?distilling cvbool { %if
  2182.         ischarpath { %ifelse
  2183.         gsave
  2184.             { currentpoint } stopped { 0 0 } if
  2185.             systemdict /moveto get exec
  2186.             pathstr false charpath flattenpath *pathbbox
  2187.         grestore
  2188.         }{ %else
  2189.         *pathbbox
  2190.         } ifelse
  2191.     } if
  2192.     } bdef
  2193.     /gsave { % def
  2194.     ?distilling cvbool { /gstates gstates 1 add store } if
  2195.     gsave
  2196.     } bdef
  2197.     /grestore { % def
  2198.     ?distilling cvbool { %if
  2199.         gstates 0 gt { %if
  2200.         /gstates gstates 1 sub store
  2201.         gstates charpathgstate lt { /ischarpath false store } if
  2202.         } if
  2203.     } if
  2204.     grestore
  2205.     } bdef
  2206.     /charpath { %def
  2207.     % need to make sure that when "stroke" or "fill" comes along
  2208.     % that the "charpath" elements are in the right place in the path...
  2209.     %- writepath
  2210.     ?distilling cvbool { %if
  2211.         checkgstate
  2212.         /ischarpath true store
  2213.         /charpathgstate gstates store
  2214.         /pathbool exch store
  2215.         /pathstr exch store
  2216.         { currentpoint } stopped { 0 0 } if thruCTM
  2217.         /pathY exch store /pathX exch store
  2218.         pathstr stringwidth rmoveto
  2219.     } if
  2220.     } bdef
  2221.     /newpath { %def
  2222.     ?distilling cvbool { gstates 0 le { /ischarpath false store } if } if
  2223.     newpath
  2224.     } bdef
  2225.  
  2226. end %adobe_distill
  2227. /setpacking where { pop setpacking } if
  2228. %%EndProcSet: distill_paintops 1.0 0
  2229.  
  2230. %%BeginProcSet: distill_guessfont 1.0 0
  2231. /setpacking where { pop currentpacking true setpacking } if
  2232. /adobe_distill dup where { pop pop }{ 165 200 add dict def } ifelse
  2233. adobe_distill begin
  2234.     /*definefont systemdict /definefont get def
  2235.     /definefont { %def
  2236.     % make a dictionary into which to put things
  2237.     % put the ORIGINAL name of the font into that dictionary
  2238.     % put the original FID in that dictionary, for easy comparison
  2239.     dup /FontType known {
  2240.         dup /FontType get 3 eq { %ifelse
  2241.         dup begin
  2242.             includeuserfonts { %if
  2243.             (%%BeginFont: ) wout 1 index writename writeNL
  2244.             currentdict maxlength writenum (dict begin) writeop
  2245.             save
  2246.                 /indentlevel ++
  2247.                 unames /Encoding true put
  2248.                 currentdict { %forall
  2249.                 exch dup /Encoding eq { %ifelse
  2250.                     indent (/) wout writename
  2251.                     writenamearray ( def) writeop indent
  2252.                 }{ %else
  2253.                     % dup unames exch true put
  2254.                     ( /) wout writename writeANY
  2255.                     (def) writeop indent
  2256.                 } ifelse
  2257.                 } forall
  2258.                 currentdict { pop unames exch true put } forall
  2259.                 currentdict { exch pop arrayusernames } forall
  2260.             restore
  2261.             indent (currentdict end\n) wout
  2262.             1 index writeANY (exch definefont pop) writeop
  2263.             (%%EndFont: ) wout 1 index writename writeNL
  2264.             } if
  2265.             currentdict /FontInfo known not
  2266.             currentdict /FontName known not or
  2267.             currentdict dup length 3 add exch maxlength ge and { %if
  2268.             % make slightly bigger version of current dictionary
  2269.             pop currentdict end
  2270.             dup maxlength 2 add dict begin
  2271.             { def } forall currentdict
  2272.             } if
  2273.             /FontInfo 5 dict def
  2274.             FontInfo begin
  2275.             /realname 2 index def
  2276.             /pleasemap magicbool def
  2277.             /pleasemap false hidebool
  2278.             end
  2279.             /FontName 2 index def
  2280.         end
  2281.         false
  2282.         }{ true } ifelse
  2283.     }{ true } ifelse
  2284.     % previous code leaves either true or false on stack
  2285.     { %if
  2286.         /Dfont exch store
  2287.      % This might be the first time we've ever seen a new
  2288.      % encoding.  If so, let's guess that we'll see lots
  2289.      % more of the vector, and give it the name "stdvec".
  2290.          Dfont begin
  2291.         %gcr FontType 1 eq STDvec cvnum 0 eq and
  2292.             STDvec cvnum 0 eq
  2293.         Encoding StandardEncoding ne and { %if
  2294.             /STDvec Encoding hashencoding hideval
  2295.             fd (/stdvec\n) *writestring
  2296.             STDvec
  2297.             StandardEncoding hashencoding eq { %ifelse
  2298.             fd (StandardEncoding ) *writestring
  2299.             }{ %else
  2300.             Encoding writenamearray
  2301.             } ifelse
  2302.             fd (def\n) *writestring
  2303.             fd (stdvec /CourierR /Courier REMAP\n) *writestring
  2304.             % checksetup
  2305.         }{ %else
  2306.             %gcr FontType 1 eq STDvec cvnum 0 eq and
  2307.             STDvec cvnum 0 eq
  2308.             Encoding StandardEncoding ne and { %if
  2309.             /PAGEvec Encoding hashencoding hideval
  2310.             fd (/pagevec\n) *writestring
  2311.             PAGEvec
  2312.             StandardEncoding hashencoding eq { %ifelse
  2313.                 fd (StandardEncoding ) *writestring
  2314.             }{ %else
  2315.                 Encoding writenamearray
  2316.             } ifelse
  2317.             fd (def\n) *writestring
  2318.             % checksetup
  2319.             } if
  2320.         } ifelse
  2321.         end
  2322.      % try to find the "real" font in FontDirectory from which this
  2323.      % font was derived, assuming it was reencoded....
  2324.         /tempfontname /Courier store
  2325.         /tempfontname /UnKnownFont store
  2326.         FontDirectory { %forall
  2327.         /Ffont exch store /Fname exch store
  2328.         % if the font was already touched, ignore it:
  2329.         Ffont /FontInfo known { %ifelse
  2330.             Ffont /FontInfo get /realname known not
  2331.         }{ true } ifelse    % leaves boolean
  2332.         { % if
  2333.             % if UniqueID's match, grab it!
  2334.             Dfont /UniqueID known Ffont /UniqueID known and {
  2335.             Dfont /UniqueID get Ffont /UniqueID get eq {
  2336.                 /tempfontname Fname store exit
  2337.             } if
  2338.             } if
  2339.         } if % /realname is not there
  2340.         } forall
  2341.         tempfontname /UnKnownFont eq { %if
  2342.           Dfont begin
  2343.         FontDirectory { %forall
  2344.           /Ffont exch store /Fname exch store
  2345.           % if CharStrings match, then compare FontMatrix.  If
  2346.           % FontMatrix matches or the *second* elements match,
  2347.           % (it might be oblique), then grab it.
  2348.           Dfont /FontType known {
  2349.             FontType 1 eq {
  2350.               Dfont/CharStrings known Ffont/CharStrings known and {
  2351.             Dfont/CharStrings get Ffont/CharStrings get eq {
  2352.               Dfont/FontMatrix known Ffont/FontMatrix known and {
  2353.                 Dfont/FontMatrix get Ffont/FontMatrix get
  2354.                 2 copy eq  3 1 roll
  2355.                 2 get exch 2 get eq or {
  2356.                 /tempfontname Fname store exit
  2357.                 } if
  2358.               } if
  2359.             } if
  2360.               } if
  2361.             } if
  2362.           } if
  2363.         } forall
  2364.           end
  2365.         } if
  2366.         tempfontname /UnKnownFont eq { %if
  2367.           FontDirectory { %forall
  2368.         /Ffont exch store /Fname exch store
  2369.           % if everything matches but some keys, grab it
  2370.           true    % start with "true" on stack
  2371.           Dfont { %forall
  2372.             exch dup /Encoding eq 1 index /FID eq or { %ifelse
  2373.             pop pop
  2374.             }{ % else
  2375.             dup Ffont exch known {
  2376.                 Ffont exch get ne { pop false exit } if
  2377.             }{ pop pop } ifelse
  2378.             } ifelse
  2379.           } forall
  2380.           % use either "true" that was there, or "false" from loop
  2381.           { %if
  2382.               /tempfontname Fname store exit
  2383.           } if
  2384.           } forall
  2385.         } if
  2386.          tempfontname /UnKnownFont eq {
  2387.         Dfont /Encoding get StandardEncoding eq
  2388.         substitutefonts or { %ifelse
  2389.           % If there is no comparable fontdict already there, and
  2390.           % if this is of FontType 1 and has StandardEncoding,
  2391.           % we guess that this is a downloadable font, and ignore it
  2392.             Dfont /FontName known {
  2393.             /tempfontname Dfont /FontName get store
  2394.             }{
  2395.             /tempfontname /Courier store
  2396.             } ifelse
  2397.             (%substituting ) wout tempfontname writename writeNL
  2398.             messages {
  2399.             (substituting: ) pr= tempfontname ==
  2400.             } if
  2401.             Dfont    % needed by *definefont below...
  2402.         }{ %else
  2403.             (ERROR: Couldn't find original fontdict to match: ) print
  2404.             Dfont /FontName get == flush
  2405.             (Fonts in FontDirectory include:) r=
  2406.             FontDirectory { pop (\040) print == } forall flush
  2407.             stop
  2408.         } ifelse
  2409.         } if
  2410.         Dfont /FontInfo known not
  2411.         Dfont /FontName known not or {
  2412.         Dfont dup length 3 add exch maxlength ge and { %if
  2413.             % make slightly bigger version of current dictionary
  2414.             Dfont maxlength 2 add dict begin
  2415.             Dfont { def } forall
  2416.             currentdict end /Dfont exch def
  2417.         } if
  2418.         } if
  2419.         Dfont dup begin
  2420.         /FontName 2 index def
  2421.         /FontInfo 5 dict def
  2422.         FontInfo begin
  2423.             /realname tempfontname def
  2424.             /pleasemap magicbool def
  2425.             /pleasemap
  2426.             tempfontname findfont /Encoding get
  2427.             StandardEncoding eq
  2428.             hidebool
  2429.         end
  2430.         end
  2431.     } if
  2432.     *definefont
  2433.     } bdef
  2434.  
  2435. end %adobe_distill
  2436. /setpacking where { pop setpacking } if
  2437. %%EndProcSet: distill_guessfont 1.0 0
  2438.  
  2439. %%BeginProcSet: hacks 0.5 0
  2440.   % defeat the "transform round exch round exch itransform" trick:
  2441.     /round { } bdef
  2442.     transformhacks {
  2443.     /transform { dup type /arraytype eq { pop } if } bdef
  2444.     /itransform { dup type /arraytype eq { pop } if } bdef
  2445.     } if
  2446.   % redefine control-D:
  2447.     (\004) { (\n%%EOF) writeop } bdef
  2448. %%EndProcSet: hacks 0.5 0
  2449.  
  2450.  adobe!ad decwrl 10/07/89
  2451. Adobe PostScript Fi icbal@asuacad       10/07/89 here is "Programs/still.ps  ..
  2452.